Tim Andersson has proposed merging
~andersson123/autopkgtest-cloud:lxd-cleanup-srv-files into
autopkgtest-cloud:master.
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/456773
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of
~andersson123/autopkgtest-cloud:lxd-cleanup-srv-files into
autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/lib/systemd.py b/charms/focal/autopkgtest-cloud-worker/lib/systemd.py
index 3df8f98..4bcca41 100644
--- a/charms/focal/autopkgtest-cloud-worker/lib/systemd.py
+++ b/charms/focal/autopkgtest-cloud-worker/lib/systemd.py
@@ -248,6 +248,21 @@ def update_lxd_dropins(arch, ip, n):
)
reload()
+def remove_old_lxd_dropins(target_lxd_config):
+ (
+ _,
+ lxd_unit_object_paths,
+ _,
+ ) = get_units()
+ all_lxd_arches = set(
+ list(lxd_unit_object_paths.keys()) + list(target_lxd_config.keys())
+ )
+ for arch in all_lxd_arches:
+ ips = target_lxd_config[arch].keys()
+ for lxd_path in lxd_unit_object_paths:
+ if "autopkgtest@" in lxd_path and [ip for ip in ips if ip not in lxd_path]:
+ os.remove(lxd_path)
+
def enable_timer(region, arch, releases):
unit_names = [
diff --git a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
index f39705d..c91b353 100644
--- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
+++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
@@ -299,6 +299,19 @@ def clear_old_rcs():
def enable_units_initially():
enable_disable_units()
+@when_any(
+ "config.set.lxd-remotes",
+)
+def remove_old_lxd_units():
+ from lib.systemd import remove_old_lxd_dropins
+ lxdremotes = config().get("lxd-remotes") or ""
+ lxdremotes_yaml = yaml.load(lxdremotes, Loader=yaml.CSafeLoader)
+ log("Removing old lxd systemd units for old remotes")
+ remove_old_lxd_dropins(lxdremotes_yaml)
+ set_flag("autopkgtest.reload-needed")
+ set_flag("autopkgtest.daemon-reload-needed")
+ set_flag("autopkgtest.target-restart-needed")
+
@when_all(
"autopkgtest.autopkgtest_cloud_symlinked",
--
Mailing list: https://launchpad.net/~canonical-ubuntu-qa
Post to : [email protected]
Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa
More help : https://help.launchpad.net/ListHelp