← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:fix-web-reactive-hanging into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:fix-web-reactive-hanging 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/461815
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:fix-web-reactive-hanging into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
index d0c33a7..14a3421 100644
--- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
+++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
@@ -62,7 +62,7 @@ def setup_rabbitmq(rabbitmq):
     "config.set.indexed-packages-fp",
 )
 def write_autopkgtest_cloud_conf(rabbitmq):
-    status.waiting("Writing autopkgtest-cloud config")
+    status.maintenance("Writing autopkgtest-cloud config")
     swiftinternal = config().get("storage-url-internal")
     hostname = config().get("hostname")
     cookies = config().get("cookies")
@@ -90,7 +90,7 @@ def write_autopkgtest_cloud_conf(rabbitmq):
             )
         )
     os.rename(f"{AUTOPKGTEST_CLOUD_CONF}.new", AUTOPKGTEST_CLOUD_CONF)
-    status.waiting("Done writing autopkgtest-cloud config")
+    status.maintenance("Done writing autopkgtest-cloud config")
     set_flag("autopkgtest-web.config-written")
 
 
@@ -99,7 +99,7 @@ def write_autopkgtest_cloud_conf(rabbitmq):
     "autopkgtest-web.config-written",
 )
 def set_up_systemd_units():
-    status.waiting("Setting up systemd units")
+    status.maintenance("Setting up systemd units")
     any_changed = False
     for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):
         base = os.path.basename(unit)
@@ -120,14 +120,16 @@ def set_up_systemd_units():
             # any_changed is true here because the systemd unit has changed on disk
             any_changed = True
         status.maintenance(f"Installing systemd unit {base}")
-        subprocess.check_call(["systemctl", "enable", base])
+        with open(unit, "r") as f:
+            unit_file = f.read()
+        if "[Install]" in unit_file:
+            subprocess.check_call(["systemctl", "enable", base])
 
     if any_changed:
         subprocess.check_call(["systemctl", "daemon-reload"])
         subprocess.check_call(
-            ["systemctl", "restart", "autopkgtest-web.target"]
+            ["systemctl", "restart", "autopkgtest-web.target", "--no-block"]
         )
-
     status.active("systemd units installed and enabled")