Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:novarcs-reactive-charm-further-fixes 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/473373 further fixes to the nova rc part of the charm, plus reverting a commit which was actually bogus -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:novarcs-reactive-charm-further-fixes into autopkgtest-cloud:master.
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 4c241eb..1b01d84 100644 --- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py +++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py @@ -334,60 +334,57 @@ def clear_rabbitmq(): status.maintenance("Done clearing rabbitmq configuration") -@when_any( - "config.set.nova-rcs", - "autopkgtest.no-nova-rcs", +@when( + "autopkgtest.write-nova-rcs", ) def update_nova_rcs(): status.maintenance("Updating nova rc files") # pylint: disable=import-outside-toplevel import base64 + import tarfile from io import BytesIO - from tarfile import TarFile rctar = config().get("nova-rcs") + b64_rctar = BytesIO(base64.b64decode(rctar)) if not rctar: # set to the empty value return + with open("/home/ubuntu/novarcs.tar", "wb") as f: + f.write(b64_rctar.getbuffer()) + log("Extracting cloud .rc files...", "INFO") clear_old_rcs() - # This previously worked in staging when deploying using terraform, - # but then laterally when deploying a new unit in production, failed. - # Leaving it commented as we may need to come back and use this in the - # future once we figure out the issue. - # bytes_file = BytesIO(bytes(rctar, encoding="utf-8")) - bytes_file = BytesIO(base64.b64decode(rctar)) - tar = TarFile(fileobj=bytes_file) + tar = tarfile.open("/home/ubuntu/novarcs.tar") + with tarfile.open("/home/ubuntu/novarcs.tar") as tar: + tar.extractall() + log("...got {}".format(", ".join(tar.getnames())), "INFO") - log("...got {}".format(", ".join(tar.getnames())), "INFO") - - tar.extractall(os.path.expanduser("~ubuntu/cloudrcs/")) + os.remove("/home/ubuntu/novarcs.tar") status.maintenance("Done updating nova rc files") - clear_flag("autopkgtest.no-nova-rcs") + clear_flag("autopkgtest.write-nova-rcs") -@when("config.default.nova-rcs") +@when( + "config.changed.nova-rcs", +) def clear_old_rcs(): status.maintenance("Cleaning old nova rc files") rcfiles = glob.glob(os.path.expanduser("~ubuntu/cloudrcs/*.rc")) - if not rcfiles: - set_flag("autopkgtest.no-nova-rcs") + if rcfiles: + log("Deleting old cloud .rc files...", "INFO") + for rcfile in rcfiles: + log("...deleting {}...".format(rcfile)) + os.unlink(rcfile) + log("...done", "INFO") + status.maintenance("Done cleaning old nova rc files") + else: status.maintenance("No old nova rc files to clear") - return - - log("Deleting old cloud .rc files...", "INFO") - - for rcfile in rcfiles: - log("...deleting {}...".format(rcfile)) - os.unlink(rcfile) - - log("...done", "INFO") - status.active("Done cleaning old nova rc files") + set_flag("autopkgtest.write-nova-rcs") @when_all( @@ -426,11 +423,9 @@ def remove_old_lxd_units(): "config.set.releases", ) @when_any( - "config.set.n-workers", "config.changed.n-workers", "config.set.lxd-remotes", "config.changed.lxd-remotes", - "config.set.releases", "config.changed.releases", ) def enable_disable_units(): @@ -562,20 +557,8 @@ def write_swift_config(): "config.changed.worker-net-names", "config.changed.worker-upstream-percentage", "config.changed.stable-release-percentage", - "config.set.worker-flavor-config", - "config.set.worker-args", - "config.set.worker-setup-command", - "config.set.worker-setup-command2", - "config.set.releases", - "config.set.n-workers", - "config.set.lxd-remotes", - "config.set.mirror", - "config.set.worker-net-names", - "config.set.worker-upstream-percentage", - "config.set.stable-release-percentage", - "config.set.nova-rcs", - "config.set.lxd-remotes", ) +@when_any("config.set.nova-rcs", "config.set.lxd-remotes") def write_worker_config(): status.maintenance("Writing worker configuration")
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp