Alberto Donato has proposed merging ~ack/maas:dns-zone-cleanup-fix into maas:master.
Commit message: Fix dns configuration set up. Fix the cleanup phase by only removing zone files, not everything Requested reviews: MAAS Maintainers (maas-maintainers) For more details, see: https://code.launchpad.net/~ack/maas/+git/maas/+merge/433280 -- Your team MAAS Maintainers is requested to review the proposed merge of ~ack/maas:dns-zone-cleanup-fix into maas:master.
diff --git a/debian/maas-region-api.postinst b/debian/maas-region-api.postinst old mode 100644 new mode 100755 index 778504d..1502dc1 --- a/debian/maas-region-api.postinst +++ b/debian/maas-region-api.postinst @@ -31,7 +31,7 @@ configure_libdir() { chown maas:maas /var/lib/maas/maas_id fi - if [ -d /var/lib/maas/bind ]; then + if [ -d /var/lib/bind/maas ]; then chown maas:bind /var/lib/bind/maas chmod 0775 /var/lib/bind/maas fi @@ -75,22 +75,10 @@ fix_dns_permissions() { # file. This does *not* overwrite any existing configuration. maas-region local_config_set -if [ "$1" = "configure" ] && [ -z "$2" ]; then +if [ "$1" = "configure" ]; then configure_logging configure_libdir - # Configure DNS - # If /etc/bind/maas is empty, setup dns. - if [ ! "$(ls -A /etc/bind/maas)" ]; then - /usr/lib/maas/maas-common setup-dns - fi - fix_dns_permissions - edit_named_options - -elif [ "$1" = "configure" ] && dpkg --compare-versions "$2" gt 0.1+bzr266+dfsg-0ubuntu1; then - # Logging changed at r2611, ensure it is set up. - configure_logging - configure_libdir - # Configure DNS + /usr/lib/maas/maas-common setup-dns fix_dns_permissions edit_named_options fi diff --git a/src/provisioningserver/dns/config.py b/src/provisioningserver/dns/config.py index 199fb76..abb059c 100644 --- a/src/provisioningserver/dns/config.py +++ b/src/provisioningserver/dns/config.py @@ -12,6 +12,7 @@ import errno import grp import os import os.path +from pathlib import Path import re import sys from typing import Optional @@ -108,11 +109,7 @@ def get_zone_file_config_dir(): so that bind can write to the location as well """ setting = os.getenv("MAAS_ZONE_FILE_CONFIG_DIR", MAAS_ZONE_FILE_DIR) - if isinstance(setting, bytes): - fsenc = sys.getfilesystemencoding() - return setting.decode(fsenc) - else: - return setting + return Path(setting) def get_bind_config_dir(): @@ -240,16 +237,14 @@ def set_up_nsupdate_key(): def clean_old_zone_files(): - p = get_zone_file_config_dir() - files = os.listdir(p) - for f in files: - os.remove(os.path.join(p, f)) + for path in get_zone_file_config_dir().glob("zone.*"): + path.unlink() def set_up_zone_file_dir(): - p = get_zone_file_config_dir() - if not os.path.exists(p): - os.mkdir(p) + path = get_zone_file_config_dir() + if not path.exists(): + path.mkdir(mode=0o775) uid = os.getuid() gid = 0 @@ -257,8 +252,7 @@ def set_up_zone_file_dir(): if group: gid = group.gr_gid - os.chown(p, uid, gid) - os.chmod(p, 0o775) + os.chown(path, uid, gid) else: clean_old_zone_files() diff --git a/src/provisioningserver/dns/tests/test_config.py b/src/provisioningserver/dns/tests/test_config.py index ca6f037..954411c 100644 --- a/src/provisioningserver/dns/tests/test_config.py +++ b/src/provisioningserver/dns/tests/test_config.py @@ -296,7 +296,7 @@ class TestRNDCUtilities(MAASTestCase): zone_file_dir = patch_zone_file_config_path(self) zonefiles = [ - os.path.join(zone_file_dir, f"zonefile{i}") + os.path.join(zone_file_dir, f"zone.{i}") for i, _ in enumerate(range(2)) ] for zonefile in zonefiles:
-- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp