Merge ~hyask/autopkgtest-cloud:skia/reactive_charm_status into autopkgtest-cloud:master

Proposed by Skia
Status: Merged
Merged at revision: 127c2d83e913154613974c313a46715606e6a133
Proposed branch: ~hyask/autopkgtest-cloud:skia/reactive_charm_status
Merge into: autopkgtest-cloud:master
Diff against target: 486 lines (+78/-2)
2 files modified
charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py (+45/-0)
charms/focal/autopkgtest-web/reactive/autopkgtest_web.py (+33/-2)
Reviewer Review Type Date Requested Status
Tim Andersson Approve
Review via email: mp+461531@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Andersson (andersson123) wrote :

one inline comment, nothing needs amending. LGTM provided CI passes!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 2e8f376..b00037f 100644
--- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
+++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
@@ -52,12 +52,16 @@ RABBITMQ_CRED_PATH = os.path.expanduser("~ubuntu/rabbitmq.cred")
5252
53@when_not("autopkgtest.autopkgtest_cloud_symlinked")53@when_not("autopkgtest.autopkgtest_cloud_symlinked")
54def symlink_autopkgtest_cloud():54def symlink_autopkgtest_cloud():
55 status.maintenance("Creating symlink to charmed autopkgtest-cloud code")
55 with UnixUser("ubuntu"):56 with UnixUser("ubuntu"):
56 try:57 try:
57 autopkgtest_cloud = os.path.join(charm_dir(), "autopkgtest-cloud")58 autopkgtest_cloud = os.path.join(charm_dir(), "autopkgtest-cloud")
58 os.symlink(autopkgtest_cloud, AUTOPKGTEST_CLOUD_LOCATION)59 os.symlink(autopkgtest_cloud, AUTOPKGTEST_CLOUD_LOCATION)
59 except FileExistsError:60 except FileExistsError:
60 pass61 pass
62 status.maintenance(
63 "Done creating symlink to charmed autopkgtest-cloud code"
64 )
61 set_flag("autopkgtest.autopkgtest_cloud_symlinked")65 set_flag("autopkgtest.autopkgtest_cloud_symlinked")
6266
6367
@@ -97,7 +101,9 @@ def clone_autopkgtest_package_configs():
97@when("autopkgtest.autodep8_cloned")101@when("autopkgtest.autodep8_cloned")
98@when_not("autopkgtest.autodep8_installed")102@when_not("autopkgtest.autodep8_installed")
99def initially_install_autodep8():103def initially_install_autodep8():
104 status.maintenance("Installing autodep8")
100 install_autodep8(AUTODEP8_LOCATION)105 install_autodep8(AUTODEP8_LOCATION)
106 status.maintenance("Done installing autodep8")
101 set_flag("autopkgtest.autodep8_installed")107 set_flag("autopkgtest.autodep8_installed")
102108
103109
@@ -125,6 +131,7 @@ def clone_autopkgtest():
125 "autopkgtest.influx-creds-written",131 "autopkgtest.influx-creds-written",
126)132)
127def set_up_systemd_units():133def set_up_systemd_units():
134 status.maintenance("Installing systemd units")
128 for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):135 for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):
129 base = os.path.basename(unit)136 base = os.path.basename(unit)
130 dest = os.path.join(os.path.sep, "etc", "systemd", "system", base)137 dest = os.path.join(os.path.sep, "etc", "systemd", "system", base)
@@ -141,30 +148,39 @@ def set_up_systemd_units():
141 if not os.path.islink(dest):148 if not os.path.islink(dest):
142 os.unlink(dest)149 os.unlink(dest)
143 link_and_enable()150 link_and_enable()
151 status.maintenance("Done installing systemd units")
144 set_flag("autopkgtest.systemd_units_linked_and_enabled")152 set_flag("autopkgtest.systemd_units_linked_and_enabled")
145153
146154
147@when("autopkgtest.systemd_units_linked_and_enabled")155@when("autopkgtest.systemd_units_linked_and_enabled")
148@when_not("autopkgtest.target_running")156@when_not("autopkgtest.target_running")
149def start():157def start():
158 status.maintenance("Enabling and starting autopkgtest systemd target")
150 subprocess.check_call(159 subprocess.check_call(
151 ["systemctl", "enable", "--now", "autopkgtest.target"]160 ["systemctl", "enable", "--now", "autopkgtest.target"]
152 )161 )
162 status.maintenance("Done enabling and starting autopkgtest systemd target")
153 set_flag("autopkgtest.target_running")163 set_flag("autopkgtest.target_running")
154164
155165
156@hook("stop")166@hook("stop")
157@when("autopkgtest.target_running")167@when("autopkgtest.target_running")
158def stop():168def stop():
169 status.maintenance("Disabling and stopping autopkgtest systemd target")
159 subprocess.check_call(170 subprocess.check_call(
160 ["systemctl", "disable", "--now", "autopkgtest.target"]171 ["systemctl", "disable", "--now", "autopkgtest.target"]
161 )172 )
173 status.maintenance(
174 "Done disabling and stopping autopkgtest systemd target"
175 )
162 clear_flag("autopkgtest.target_running")176 clear_flag("autopkgtest.target_running")
163177
164178
165@when_all("autopkgtest.target-restart-needed", "autopkgtest.target_running")179@when_all("autopkgtest.target-restart-needed", "autopkgtest.target_running")
166def restart_target():180def restart_target():
181 status.maintenance("Restarting autopkgtest systemd target")
167 subprocess.check_call(["systemctl", "restart", "autopkgtest.target"])182 subprocess.check_call(["systemctl", "restart", "autopkgtest.target"])
183 status.maintenance("Done restarting autopkgtest systemd target")
168 clear_flag("autopkgtest.target-restart-needed")184 clear_flag("autopkgtest.target-restart-needed")
169185
170186
@@ -180,7 +196,9 @@ def is_active():
180)196)
181@hook("upgrade-charm")197@hook("upgrade-charm")
182def daemon_reload():198def daemon_reload():
199 status.maintenance("Reloading systemd configuration after change")
183 subprocess.check_call(["systemctl", "daemon-reload"])200 subprocess.check_call(["systemctl", "daemon-reload"])
201 status.maintenance("Done reloading systemd configuration after change")
184 clear_flag("autopkgtest.daemon-reload-needed")202 clear_flag("autopkgtest.daemon-reload-needed")
185203
186204
@@ -193,6 +211,7 @@ def install_apt_packages():
193211
194@hook("install")212@hook("install")
195def enable_persistent_journal():213def enable_persistent_journal():
214 status.maintenance("Enabling persistent journal")
196 try:215 try:
197 journal_dir = os.path.join(os.path.sep, "var", "log", "journal")216 journal_dir = os.path.join(os.path.sep, "var", "log", "journal")
198 os.makedirs(journal_dir)217 os.makedirs(journal_dir)
@@ -202,6 +221,7 @@ def enable_persistent_journal():
202 subprocess.check_call(["systemctl", "restart", "systemd-journald"])221 subprocess.check_call(["systemctl", "restart", "systemd-journald"])
203 except FileExistsError:222 except FileExistsError:
204 pass223 pass
224 status.maintenance("Done enabling persistent journal")
205225
206226
207@when("amqp.connected")227@when("amqp.connected")
@@ -237,16 +257,19 @@ def set_up_rabbitmq(rabbitmq):
237257
238@when_not("amqp.available")258@when_not("amqp.available")
239def clear_rabbitmq():259def clear_rabbitmq():
260 status.maintenance("clearing rabbitmq configuration")
240 try:261 try:
241 log("rabbitmq not available, deleting credentials file")262 log("rabbitmq not available, deleting credentials file")
242 os.unlink(RABBITMQ_CRED_PATH)263 os.unlink(RABBITMQ_CRED_PATH)
243 clear_flag("autopkgtest.rabbitmq-configured")264 clear_flag("autopkgtest.rabbitmq-configured")
244 except FileNotFoundError:265 except FileNotFoundError:
245 pass266 pass
267 status.maintenance("Done clearing rabbitmq configuration")
246268
247269
248@when("config.changed.nova-rcs")270@when("config.changed.nova-rcs")
249def update_nova_rcs():271def update_nova_rcs():
272 status.maintenance("Updating nova rc files")
250 # pylint: disable=import-outside-toplevel273 # pylint: disable=import-outside-toplevel
251 import base64274 import base64
252 from io import BytesIO275 from io import BytesIO
@@ -268,10 +291,12 @@ def update_nova_rcs():
268 log("...got {}".format(", ".join(tar.getnames())), "INFO")291 log("...got {}".format(", ".join(tar.getnames())), "INFO")
269292
270 tar.extractall(os.path.expanduser("~ubuntu/cloudrcs/"))293 tar.extractall(os.path.expanduser("~ubuntu/cloudrcs/"))
294 status.maintenance("Done updating nova rc files")
271295
272296
273@when("config.default.nova-rcs")297@when("config.default.nova-rcs")
274def clear_old_rcs():298def clear_old_rcs():
299 status.maintenance("Cleaning old nova rc files")
275 rcfiles = glob.glob(os.path.expanduser("~ubuntu/cloudrcs/*.rc"))300 rcfiles = glob.glob(os.path.expanduser("~ubuntu/cloudrcs/*.rc"))
276301
277 if not rcfiles:302 if not rcfiles:
@@ -284,6 +309,7 @@ def clear_old_rcs():
284 os.unlink(rcfile)309 os.unlink(rcfile)
285310
286 log("...done", "INFO")311 log("...done", "INFO")
312 status.maintenance("Done cleaning old nova rc files")
287313
288314
289@when_all(315@when_all(
@@ -327,6 +353,8 @@ def enable_disable_units():
327 nworkers_yaml or {}, lxdremotes_yaml or {}, releases.split()353 nworkers_yaml or {}, lxdremotes_yaml or {}, releases.split()
328 )354 )
329355
356 status.maintenance("Done enabling and starting worker units")
357
330 set_flag("autopkgtest.reload-needed")358 set_flag("autopkgtest.reload-needed")
331 set_flag("autopkgtest.daemon-reload-needed")359 set_flag("autopkgtest.daemon-reload-needed")
332 set_flag("autopkgtest.target-restart-needed")360 set_flag("autopkgtest.target-restart-needed")
@@ -339,7 +367,9 @@ def enable_disable_units():
339)367)
340@when_not("autopkgtest.ubuntu_added_to_lxd_group")368@when_not("autopkgtest.ubuntu_added_to_lxd_group")
341def add_ubuntu_user_to_lxd_group():369def add_ubuntu_user_to_lxd_group():
370 status.maintenance("Adding ubuntu user to lxd group")
342 subprocess.check_call(["adduser", "ubuntu", "lxd"])371 subprocess.check_call(["adduser", "ubuntu", "lxd"])
372 status.maintenance("Done adding ubuntu user to lxd group")
343 set_flag("autopkgtest.ubuntu_added_to_lxd_group")373 set_flag("autopkgtest.ubuntu_added_to_lxd_group")
344374
345375
@@ -405,6 +435,7 @@ def write_v2_config():
405435
406436
407def write_swift_config():437def write_swift_config():
438 status.maintenance("Writing swift configuration")
408 with open(439 with open(
409 os.path.expanduser("~ubuntu/swift-password.cred"), "w"440 os.path.expanduser("~ubuntu/swift-password.cred"), "w"
410 ) as swift_password_file:441 ) as swift_password_file:
@@ -416,6 +447,7 @@ def write_swift_config():
416 str(config()[key]).strip(),447 str(config()[key]).strip(),
417 )448 )
418 )449 )
450 status.maintenance("Done writing swift configuration")
419451
420452
421@when_any(453@when_any(
@@ -432,6 +464,8 @@ def write_swift_config():
432)464)
433@when_any("config.set.nova-rcs", "config.set.lxd-remotes")465@when_any("config.set.nova-rcs", "config.set.lxd-remotes")
434def write_worker_config():466def write_worker_config():
467 status.maintenance("Writing worker configuration")
468
435 # pylint: disable=import-outside-toplevel469 # pylint: disable=import-outside-toplevel
436 import configparser470 import configparser
437471
@@ -523,23 +557,28 @@ def write_worker_config():
523 conf["autopkgtest"]["architectures"] = arch557 conf["autopkgtest"]["architectures"] = arch
524 write(conf_file)558 write(conf_file)
525559
560 status.maintenance("Done writing worker configuration")
526 set_flag("autopkgtest.daemon-reload-needed")561 set_flag("autopkgtest.daemon-reload-needed")
527 set_flag("autopkgtest.reload-needed")562 set_flag("autopkgtest.reload-needed")
528563
529564
530@when("config.changed.net-name")565@when("config.changed.net-name")
531def write_net_name():566def write_net_name():
567 status.maintenance("Writing net-name configuration")
532 clear_flag("autopkgtest.net-name-written")568 clear_flag("autopkgtest.net-name-written")
533 with open(os.path.expanduser("~ubuntu/net-name.rc"), "w") as f:569 with open(os.path.expanduser("~ubuntu/net-name.rc"), "w") as f:
534 f.write('NET_NAME="{}"\n'.format(config().get("net-name")))570 f.write('NET_NAME="{}"\n'.format(config().get("net-name")))
571 status.maintenance("Done writing net-name configuration")
535 set_flag("autopkgtest.net-name-written")572 set_flag("autopkgtest.net-name-written")
536 set_flag("autopkgtest.reload-needed")573 set_flag("autopkgtest.reload-needed")
537574
538575
539@when("config.changed.mirror")576@when("config.changed.mirror")
540def write_mirror():577def write_mirror():
578 status.maintenance("Writing mirror configuration")
541 with open(os.path.expanduser("~ubuntu/mirror.rc"), "w") as f:579 with open(os.path.expanduser("~ubuntu/mirror.rc"), "w") as f:
542 f.write('MIRROR="{}"\n'.format(config().get("mirror")))580 f.write('MIRROR="{}"\n'.format(config().get("mirror")))
581 status.maintenance("Done writing mirror configuration")
543 set_flag("autopkgtest.reload-needed")582 set_flag("autopkgtest.reload-needed")
544583
545584
@@ -555,6 +594,7 @@ def reload_systemd_units():
555594
556@hook("tmp-storage-attached")595@hook("tmp-storage-attached")
557def fix_tmp_permissions():596def fix_tmp_permissions():
597 status.maintenance("Fixing tmp permissions")
558 storageids = storage_list("tmp")598 storageids = storage_list("tmp")
559 if not storageids:599 if not storageids:
560 status.blocked("Cannot locate attached storage")600 status.blocked("Cannot locate attached storage")
@@ -564,6 +604,7 @@ def fix_tmp_permissions():
564 mount = storage_get("location", storageid)604 mount = storage_get("location", storageid)
565605
566 os.chmod(mount, 0o777)606 os.chmod(mount, 0o777)
607 status.maintenance("Done fixing tmp permissions")
567608
568609
569@when_any(610@when_any(
@@ -583,6 +624,7 @@ def fix_tmp_permissions():
583 "config.set.influxdb-context",624 "config.set.influxdb-context",
584)625)
585def write_influx_creds():626def write_influx_creds():
627 status.maintenance("Writing influxdb credentials")
586 influxdb_hostname = config().get("influxdb-hostname")628 influxdb_hostname = config().get("influxdb-hostname")
587 influxdb_port = config().get("influxdb-port")629 influxdb_port = config().get("influxdb-port")
588 influxdb_username = config().get("influxdb-username")630 influxdb_username = config().get("influxdb-username")
@@ -603,6 +645,7 @@ def write_influx_creds():
603 """645 """
604 )646 )
605 )647 )
648 status.maintenance("Done writing influxdb credentials")
606 set_flag("autopkgtest.influx-creds-written")649 set_flag("autopkgtest.influx-creds-written")
607650
608651
@@ -615,8 +658,10 @@ def write_influx_creds():
615 "config.set.influxdb-context",658 "config.set.influxdb-context",
616)659)
617def unset_influx_creds():660def unset_influx_creds():
661 status.maintenance("Deleting influxdb credentials")
618 try:662 try:
619 os.unlink(os.path.expanduser("~ubuntu/influx.cred"))663 os.unlink(os.path.expanduser("~ubuntu/influx.cred"))
620 except FileNotFoundError:664 except FileNotFoundError:
621 pass665 pass
666 status.maintenance("Done deleting influxdb credentials")
622 clear_flag("autopkgtest.influx-creds-written")667 clear_flag("autopkgtest.influx-creds-written")
diff --git a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
index 6920fc1..d0c33a7 100644
--- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
+++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
@@ -37,12 +37,14 @@ def install_apt_packages():
3737
38@when_not("autopkgtest-web.autopkgtest_web_symlinked")38@when_not("autopkgtest-web.autopkgtest_web_symlinked")
39def symlink_autopkgtest_cloud():39def symlink_autopkgtest_cloud():
40 status.maintenance("Creating symlink to charmed autopkgtest-web code")
40 try:41 try:
41 autopkgtest_cloud = os.path.join(charm_dir(), "webcontrol")42 autopkgtest_cloud = os.path.join(charm_dir(), "webcontrol")
42 os.symlink(autopkgtest_cloud, os.path.expanduser("~ubuntu/webcontrol"))43 os.symlink(autopkgtest_cloud, os.path.expanduser("~ubuntu/webcontrol"))
43 set_flag("autopkgtest-web.autopkgtest_web_symlinked")
44 except FileExistsError:44 except FileExistsError:
45 pass45 pass
46 status.maintenance("Done creating symlink to charmed autopkgtest-web code")
47 set_flag("autopkgtest-web.autopkgtest_web_symlinked")
4648
4749
48@when("amqp.connected")50@when("amqp.connected")
@@ -60,6 +62,7 @@ def setup_rabbitmq(rabbitmq):
60 "config.set.indexed-packages-fp",62 "config.set.indexed-packages-fp",
61)63)
62def write_autopkgtest_cloud_conf(rabbitmq):64def write_autopkgtest_cloud_conf(rabbitmq):
65 status.waiting("Writing autopkgtest-cloud config")
63 swiftinternal = config().get("storage-url-internal")66 swiftinternal = config().get("storage-url-internal")
64 hostname = config().get("hostname")67 hostname = config().get("hostname")
65 cookies = config().get("cookies")68 cookies = config().get("cookies")
@@ -87,6 +90,7 @@ def write_autopkgtest_cloud_conf(rabbitmq):
87 )90 )
88 )91 )
89 os.rename(f"{AUTOPKGTEST_CLOUD_CONF}.new", AUTOPKGTEST_CLOUD_CONF)92 os.rename(f"{AUTOPKGTEST_CLOUD_CONF}.new", AUTOPKGTEST_CLOUD_CONF)
93 status.waiting("Done writing autopkgtest-cloud config")
90 set_flag("autopkgtest-web.config-written")94 set_flag("autopkgtest-web.config-written")
9195
9296
@@ -95,6 +99,7 @@ def write_autopkgtest_cloud_conf(rabbitmq):
95 "autopkgtest-web.config-written",99 "autopkgtest-web.config-written",
96)100)
97def set_up_systemd_units():101def set_up_systemd_units():
102 status.waiting("Setting up systemd units")
98 any_changed = False103 any_changed = False
99 for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):104 for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):
100 base = os.path.basename(unit)105 base = os.path.basename(unit)
@@ -114,7 +119,7 @@ def set_up_systemd_units():
114 if "NeedDaemonReload=yes" in p.stdout:119 if "NeedDaemonReload=yes" in p.stdout:
115 # any_changed is true here because the systemd unit has changed on disk120 # any_changed is true here because the systemd unit has changed on disk
116 any_changed = True121 any_changed = True
117 status.maintenance("Installing systemd units")122 status.maintenance(f"Installing systemd unit {base}")
118 subprocess.check_call(["systemctl", "enable", base])123 subprocess.check_call(["systemctl", "enable", base])
119124
120 if any_changed:125 if any_changed:
@@ -149,6 +154,7 @@ def initially_configure_website(website):
149 "autopkgtest-web.website-initially-configured",154 "autopkgtest-web.website-initially-configured",
150)155)
151def set_up_web_config(apache):156def set_up_web_config(apache):
157 status.maintenance("Setting up web config (apache)")
152 webcontrol_dir = os.path.join(charm_dir(), "webcontrol")158 webcontrol_dir = os.path.join(charm_dir(), "webcontrol")
153 sn = config().get("hostname")159 sn = config().get("hostname")
154 https_proxy = config().get("https-proxy")160 https_proxy = config().get("https-proxy")
@@ -231,6 +237,7 @@ def set_up_web_config(apache):
231 )237 )
232 )238 )
233 )239 )
240 status.maintenance("Done setting up web config (apache)")
234 set_flag("autopkgtest-web.website-initially-configured")241 set_flag("autopkgtest-web.website-initially-configured")
235 apache.send_ports([80]) # haproxy is doing SSL termination242 apache.send_ports([80]) # haproxy is doing SSL termination
236 apache.send_enabled()243 apache.send_enabled()
@@ -238,6 +245,7 @@ def set_up_web_config(apache):
238245
239@when_all("config.changed.github-secrets", "config.set.github-secrets")246@when_all("config.changed.github-secrets", "config.set.github-secrets")
240def write_github_secrets():247def write_github_secrets():
248 status.maintenance("Writing github secrets")
241 github_secrets = config().get("github-secrets")249 github_secrets = config().get("github-secrets")
242250
243 with open(GITHUB_SECRETS_PATH, "w") as f:251 with open(GITHUB_SECRETS_PATH, "w") as f:
@@ -250,10 +258,12 @@ def write_github_secrets():
250 )258 )
251 except FileExistsError:259 except FileExistsError:
252 pass260 pass
261 status.maintenance("Done writing github secrets")
253262
254263
255@when_not("config.set.github-secrets")264@when_not("config.set.github-secrets")
256def clear_github_secrets():265def clear_github_secrets():
266 status.maintenance("Clearing github secrets")
257 try:267 try:
258 os.unlink(GITHUB_SECRETS_PATH)268 os.unlink(GITHUB_SECRETS_PATH)
259 except FileNotFoundError:269 except FileNotFoundError:
@@ -263,12 +273,14 @@ def clear_github_secrets():
263 os.unlink(os.path.expanduser("~www-data/github-secrets.json"))273 os.unlink(os.path.expanduser("~www-data/github-secrets.json"))
264 except FileNotFoundError:274 except FileNotFoundError:
265 pass275 pass
276 status.maintenance("Done clearing github secrets")
266277
267278
268@when_all(279@when_all(
269 "config.changed.swift-web-credentials", "config.set.swift-web-credentials"280 "config.changed.swift-web-credentials", "config.set.swift-web-credentials"
270)281)
271def write_swift_web_credentials():282def write_swift_web_credentials():
283 status.maintenance("Writing swift web credentials")
272 swift_credentials = config().get("swift-web-credentials")284 swift_credentials = config().get("swift-web-credentials")
273285
274 with open(SWIFT_WEB_CREDENTIALS_PATH, "w") as f:286 with open(SWIFT_WEB_CREDENTIALS_PATH, "w") as f:
@@ -281,18 +293,22 @@ def write_swift_web_credentials():
281 )293 )
282 except FileExistsError:294 except FileExistsError:
283 pass295 pass
296 status.maintenance("Done writing swift web credentials")
284297
285298
286@when_all("config.changed.public-swift-creds", "config.set.public-swift-creds")299@when_all("config.changed.public-swift-creds", "config.set.public-swift-creds")
287def write_openstack_creds():300def write_openstack_creds():
301 status.maintenance("Writing openstack credentials")
288 public_swift_creds = config().get("public-swift-creds")302 public_swift_creds = config().get("public-swift-creds")
289303
290 with open(PUBLIC_SWIFT_CREDS_PATH, "w") as f:304 with open(PUBLIC_SWIFT_CREDS_PATH, "w") as f:
291 f.write(public_swift_creds)305 f.write(public_swift_creds)
306 status.maintenance("Done writing openstack credentials")
292307
293308
294@when_not("config.set.swift-web-credentials")309@when_not("config.set.swift-web-credentials")
295def clear_swift_web_credentials():310def clear_swift_web_credentials():
311 status.maintenance("Clearing swift web credentials")
296 try:312 try:
297 os.unlink(SWIFT_WEB_CREDENTIALS_PATH)313 os.unlink(SWIFT_WEB_CREDENTIALS_PATH)
298 except FileNotFoundError:314 except FileNotFoundError:
@@ -302,6 +318,7 @@ def clear_swift_web_credentials():
302 os.unlink(os.path.expanduser("~www-data/swift-web-credentials.conf"))318 os.unlink(os.path.expanduser("~www-data/swift-web-credentials.conf"))
303 except FileNotFoundError:319 except FileNotFoundError:
304 pass320 pass
321 status.maintenance("Done clearing swift web credentials")
305322
306323
307@when_all(324@when_all(
@@ -309,6 +326,7 @@ def clear_swift_web_credentials():
309 "config.set.github-status-credentials",326 "config.set.github-status-credentials",
310)327)
311def write_github_status_credentials():328def write_github_status_credentials():
329 status.maintenance("Writing github status credentials")
312 github_status_credentials = config().get("github-status-credentials")330 github_status_credentials = config().get("github-status-credentials")
313331
314 with open(GITHUB_STATUS_CREDENTIALS_PATH, "w") as f:332 with open(GITHUB_STATUS_CREDENTIALS_PATH, "w") as f:
@@ -321,10 +339,12 @@ def write_github_status_credentials():
321 )339 )
322 except FileExistsError:340 except FileExistsError:
323 pass341 pass
342 status.maintenance("Done writing github status credentials")
324343
325344
326@when_not("config.set.github-status-credentials")345@when_not("config.set.github-status-credentials")
327def clear_github_status_credentials():346def clear_github_status_credentials():
347 status.maintenance("Clearing github status credentials")
328 try:348 try:
329 os.unlink(GITHUB_STATUS_CREDENTIALS_PATH)349 os.unlink(GITHUB_STATUS_CREDENTIALS_PATH)
330 except FileNotFoundError:350 except FileNotFoundError:
@@ -336,18 +356,22 @@ def clear_github_status_credentials():
336 )356 )
337 except FileNotFoundError:357 except FileNotFoundError:
338 pass358 pass
359 status.maintenance("Done clearing github status credentials")
339360
340361
341@when_not("autopkgtest-web.runtime-dir-created")362@when_not("autopkgtest-web.runtime-dir-created")
342def make_runtime_tmpfiles():363def make_runtime_tmpfiles():
364 status.maintenance("Making runtime tmpfiles")
343 with open("/etc/tmpfiles.d/autopkgtest-web-runtime.conf", "w") as r:365 with open("/etc/tmpfiles.d/autopkgtest-web-runtime.conf", "w") as r:
344 r.write("D %t/autopkgtest_webcontrol 0755 www-data www-data\n")366 r.write("D %t/autopkgtest_webcontrol 0755 www-data www-data\n")
345 subprocess.check_call(["systemd-tmpfiles", "--create"])367 subprocess.check_call(["systemd-tmpfiles", "--create"])
368 status.maintenance("Done making runtime tmpfiles")
346 set_flag("autopkgtest-web.runtime-dir-created")369 set_flag("autopkgtest-web.runtime-dir-created")
347370
348371
349@when_not("autopkgtest-web.running-json-symlinked")372@when_not("autopkgtest-web.running-json-symlinked")
350def symlink_running():373def symlink_running():
374 status.maintenance("Creating symlink to running.json")
351 try:375 try:
352 os.symlink(376 os.symlink(
353 os.path.join(377 os.path.join(
@@ -355,6 +379,7 @@ def symlink_running():
355 ),379 ),
356 os.path.join(charm_dir(), "webcontrol", "static", "running.json"),380 os.path.join(charm_dir(), "webcontrol", "static", "running.json"),
357 )381 )
382 status.maintenance("Done creating symlink to running.json")
358 set_flag("autopkgtest-web.running-json-symlinked")383 set_flag("autopkgtest-web.running-json-symlinked")
359 except FileExistsError:384 except FileExistsError:
360 pass385 pass
@@ -362,6 +387,7 @@ def symlink_running():
362387
363@when_not("autopkgtest-web.public-db-symlinked")388@when_not("autopkgtest-web.public-db-symlinked")
364def symlink_public_db():389def symlink_public_db():
390 status.maintenance("Creating symlink for public database")
365 try:391 try:
366 publicdir = os.path.expanduser("~ubuntu/public/")392 publicdir = os.path.expanduser("~ubuntu/public/")
367 os.makedirs(publicdir)393 os.makedirs(publicdir)
@@ -372,6 +398,7 @@ def symlink_public_db():
372 charm_dir(), "webcontrol", "static", "autopkgtest.db"398 charm_dir(), "webcontrol", "static", "autopkgtest.db"
373 ),399 ),
374 )400 )
401 status.maintenance("Done creating symlink for public database")
375 set_flag("autopkgtest-web.public-db-symlinked")402 set_flag("autopkgtest-web.public-db-symlinked")
376 except FileExistsError:403 except FileExistsError:
377 pass404 pass
@@ -380,15 +407,19 @@ def symlink_public_db():
380@when("leadership.is_leader")407@when("leadership.is_leader")
381@when_not("autopkgtest-cloud.leadership_flag_written")408@when_not("autopkgtest-cloud.leadership_flag_written")
382def write_leadership_flag():409def write_leadership_flag():
410 status.maintenance("Setting leader")
383 with open("/run/autopkgtest-web-is-leader", "w") as _:411 with open("/run/autopkgtest-web-is-leader", "w") as _:
412 status.maintenance("Done setting leader")
384 set_flag("autopkgtest-cloud.leadership_flag_written")413 set_flag("autopkgtest-cloud.leadership_flag_written")
385414
386415
387@when_not("leadership.is_leader")416@when_not("leadership.is_leader")
388@when("autopkgtest-cloud.leadership_flag_written")417@when("autopkgtest-cloud.leadership_flag_written")
389def clear_leadership_flag():418def clear_leadership_flag():
419 status.maintenance("Clearing leader")
390 try:420 try:
391 os.unlink("/run/autopkgtest-web-is-leader")421 os.unlink("/run/autopkgtest-web-is-leader")
392 except FileNotFoundError:422 except FileNotFoundError:
393 pass423 pass
424 status.maintenance("Done clearing leader")
394 clear_flag("autopkgtest-cloud.leadership_flag_written")425 clear_flag("autopkgtest-cloud.leadership_flag_written")

Subscribers

People subscribed via source and target branches