← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:web-daemon-reload-when-service-file-change into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:web-daemon-reload-when-service-file-change 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/456622
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:web-daemon-reload-when-service-file-change 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 db60fcb..969c31b 100644
--- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
+++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
@@ -90,16 +90,27 @@ def set_up_systemd_units():
     any_changed = False
     for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):
         base = os.path.basename(unit)
+        if os.path.isfile(unit):
+            existing = ""
+            new = ""
+            with open(unit, "r") as f:
+                existing = f.read()
+            with open(
+                os.path.join(os.path.sep, "etc", "systemd", "system", base),
+                "r",
+            ) as f:
+                new = f.read()
+            if existing != new:
+                any_changed = True
         try:
             os.symlink(
                 unit,
                 os.path.join(os.path.sep, "etc", "systemd", "system", base),
             )
-            any_changed = True
-            status.maintenance("Installing systemd units")
-            subprocess.check_call(["systemctl", "enable", base])
         except FileExistsError:
             pass
+        status.maintenance("Installing systemd units")
+        subprocess.check_call(["systemctl", "enable", base])
 
     if any_changed:
         subprocess.check_call(["systemctl", "daemon-reload"])

Follow ups