canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #03536
[Merge] ~andersson123/autopkgtest-cloud:make-setup-command2-optional into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:make-setup-command2-optional 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/463126
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:make-setup-command2-optional 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 b00037f..a0289af 100644
--- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
+++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
@@ -1,5 +1,6 @@
# pylint: disable=missing-module-docstring,missing-function-docstring
import glob
+import json
import os
import socket
import subprocess
@@ -52,16 +53,12 @@ RABBITMQ_CRED_PATH = os.path.expanduser("~ubuntu/rabbitmq.cred")
@when_not("autopkgtest.autopkgtest_cloud_symlinked")
def symlink_autopkgtest_cloud():
- status.maintenance("Creating symlink to charmed autopkgtest-cloud code")
with UnixUser("ubuntu"):
try:
autopkgtest_cloud = os.path.join(charm_dir(), "autopkgtest-cloud")
os.symlink(autopkgtest_cloud, AUTOPKGTEST_CLOUD_LOCATION)
except FileExistsError:
pass
- status.maintenance(
- "Done creating symlink to charmed autopkgtest-cloud code"
- )
set_flag("autopkgtest.autopkgtest_cloud_symlinked")
@@ -101,9 +98,7 @@ def clone_autopkgtest_package_configs():
@when("autopkgtest.autodep8_cloned")
@when_not("autopkgtest.autodep8_installed")
def initially_install_autodep8():
- status.maintenance("Installing autodep8")
install_autodep8(AUTODEP8_LOCATION)
- status.maintenance("Done installing autodep8")
set_flag("autopkgtest.autodep8_installed")
@@ -131,7 +126,6 @@ def clone_autopkgtest():
"autopkgtest.influx-creds-written",
)
def set_up_systemd_units():
- status.maintenance("Installing systemd units")
for unit in glob.glob(os.path.join(charm_dir(), "units", "*")):
base = os.path.basename(unit)
dest = os.path.join(os.path.sep, "etc", "systemd", "system", base)
@@ -148,39 +142,30 @@ def set_up_systemd_units():
if not os.path.islink(dest):
os.unlink(dest)
link_and_enable()
- status.maintenance("Done installing systemd units")
set_flag("autopkgtest.systemd_units_linked_and_enabled")
@when("autopkgtest.systemd_units_linked_and_enabled")
@when_not("autopkgtest.target_running")
def start():
- status.maintenance("Enabling and starting autopkgtest systemd target")
subprocess.check_call(
["systemctl", "enable", "--now", "autopkgtest.target"]
)
- status.maintenance("Done enabling and starting autopkgtest systemd target")
set_flag("autopkgtest.target_running")
@hook("stop")
@when("autopkgtest.target_running")
def stop():
- status.maintenance("Disabling and stopping autopkgtest systemd target")
subprocess.check_call(
["systemctl", "disable", "--now", "autopkgtest.target"]
)
- status.maintenance(
- "Done disabling and stopping autopkgtest systemd target"
- )
clear_flag("autopkgtest.target_running")
@when_all("autopkgtest.target-restart-needed", "autopkgtest.target_running")
def restart_target():
- status.maintenance("Restarting autopkgtest systemd target")
subprocess.check_call(["systemctl", "restart", "autopkgtest.target"])
- status.maintenance("Done restarting autopkgtest systemd target")
clear_flag("autopkgtest.target-restart-needed")
@@ -196,9 +181,7 @@ def is_active():
)
@hook("upgrade-charm")
def daemon_reload():
- status.maintenance("Reloading systemd configuration after change")
subprocess.check_call(["systemctl", "daemon-reload"])
- status.maintenance("Done reloading systemd configuration after change")
clear_flag("autopkgtest.daemon-reload-needed")
@@ -211,7 +194,6 @@ def install_apt_packages():
@hook("install")
def enable_persistent_journal():
- status.maintenance("Enabling persistent journal")
try:
journal_dir = os.path.join(os.path.sep, "var", "log", "journal")
os.makedirs(journal_dir)
@@ -221,7 +203,6 @@ def enable_persistent_journal():
subprocess.check_call(["systemctl", "restart", "systemd-journald"])
except FileExistsError:
pass
- status.maintenance("Done enabling persistent journal")
@when("amqp.connected")
@@ -257,19 +238,16 @@ def set_up_rabbitmq(rabbitmq):
@when_not("amqp.available")
def clear_rabbitmq():
- status.maintenance("clearing rabbitmq configuration")
try:
log("rabbitmq not available, deleting credentials file")
os.unlink(RABBITMQ_CRED_PATH)
clear_flag("autopkgtest.rabbitmq-configured")
except FileNotFoundError:
pass
- status.maintenance("Done clearing rabbitmq configuration")
@when("config.changed.nova-rcs")
def update_nova_rcs():
- status.maintenance("Updating nova rc files")
# pylint: disable=import-outside-toplevel
import base64
from io import BytesIO
@@ -291,12 +269,10 @@ def update_nova_rcs():
log("...got {}".format(", ".join(tar.getnames())), "INFO")
tar.extractall(os.path.expanduser("~ubuntu/cloudrcs/"))
- status.maintenance("Done updating nova rc files")
@when("config.default.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:
@@ -309,7 +285,6 @@ def clear_old_rcs():
os.unlink(rcfile)
log("...done", "INFO")
- status.maintenance("Done cleaning old nova rc files")
@when_all(
@@ -333,6 +308,7 @@ def enable_units_initially():
)
@when_any(
"config.changed.n-workers",
+ "config.set.lxd-remotes",
"config.changed.lxd-remotes",
"config.changed.releases",
)
@@ -352,8 +328,10 @@ def enable_disable_units():
set_up_systemd_units(
nworkers_yaml or {}, lxdremotes_yaml or {}, releases.split()
)
-
- status.maintenance("Done enabling and starting worker units")
+ if lxdremotes_yaml != {}:
+ write_me = {"remotes": list(lxdremotes_yaml["armhf"].keys())}
+ with open("/home/ubuntu/lxd-remotes.json", "w") as f:
+ json.dump(write_me, f)
set_flag("autopkgtest.reload-needed")
set_flag("autopkgtest.daemon-reload-needed")
@@ -367,9 +345,7 @@ def enable_disable_units():
)
@when_not("autopkgtest.ubuntu_added_to_lxd_group")
def add_ubuntu_user_to_lxd_group():
- status.maintenance("Adding ubuntu user to lxd group")
subprocess.check_call(["adduser", "ubuntu", "lxd"])
- status.maintenance("Done adding ubuntu user to lxd group")
set_flag("autopkgtest.ubuntu_added_to_lxd_group")
@@ -435,7 +411,6 @@ def write_v2_config():
def write_swift_config():
- status.maintenance("Writing swift configuration")
with open(
os.path.expanduser("~ubuntu/swift-password.cred"), "w"
) as swift_password_file:
@@ -447,7 +422,6 @@ def write_swift_config():
str(config()[key]).strip(),
)
)
- status.maintenance("Done writing swift configuration")
@when_any(
@@ -464,8 +438,6 @@ def write_swift_config():
)
@when_any("config.set.nova-rcs", "config.set.lxd-remotes")
def write_worker_config():
- status.maintenance("Writing worker configuration")
-
# pylint: disable=import-outside-toplevel
import configparser
@@ -483,7 +455,6 @@ def write_worker_config():
"checkout_dir": AUTOPKGTEST_LOCATION,
"releases": config().get("releases"),
"setup_command": config().get("worker-setup-command"),
- "setup_command2": config().get("worker-setup-command2"),
"per_package_config_dir": AUTOPKGTEST_PER_PACKAGE_LOCATION,
},
"virt": {
@@ -492,6 +463,8 @@ def write_worker_config():
"args": config().get("worker-args"),
},
}
+ if config().get("worker-setup-command2") != "":
+ conf["autopkgtest"]["setup_command2"] = config().get("worker-setup-command2")
def subst(s):
replacements = {
@@ -557,28 +530,23 @@ def write_worker_config():
conf["autopkgtest"]["architectures"] = arch
write(conf_file)
- status.maintenance("Done writing worker configuration")
set_flag("autopkgtest.daemon-reload-needed")
set_flag("autopkgtest.reload-needed")
@when("config.changed.net-name")
def write_net_name():
- status.maintenance("Writing net-name configuration")
clear_flag("autopkgtest.net-name-written")
with open(os.path.expanduser("~ubuntu/net-name.rc"), "w") as f:
f.write('NET_NAME="{}"\n'.format(config().get("net-name")))
- status.maintenance("Done writing net-name configuration")
set_flag("autopkgtest.net-name-written")
set_flag("autopkgtest.reload-needed")
@when("config.changed.mirror")
def write_mirror():
- status.maintenance("Writing mirror configuration")
with open(os.path.expanduser("~ubuntu/mirror.rc"), "w") as f:
f.write('MIRROR="{}"\n'.format(config().get("mirror")))
- status.maintenance("Done writing mirror configuration")
set_flag("autopkgtest.reload-needed")
@@ -594,7 +562,6 @@ def reload_systemd_units():
@hook("tmp-storage-attached")
def fix_tmp_permissions():
- status.maintenance("Fixing tmp permissions")
storageids = storage_list("tmp")
if not storageids:
status.blocked("Cannot locate attached storage")
@@ -604,7 +571,6 @@ def fix_tmp_permissions():
mount = storage_get("location", storageid)
os.chmod(mount, 0o777)
- status.maintenance("Done fixing tmp permissions")
@when_any(
@@ -624,7 +590,6 @@ def fix_tmp_permissions():
"config.set.influxdb-context",
)
def write_influx_creds():
- status.maintenance("Writing influxdb credentials")
influxdb_hostname = config().get("influxdb-hostname")
influxdb_port = config().get("influxdb-port")
influxdb_username = config().get("influxdb-username")
@@ -645,7 +610,6 @@ def write_influx_creds():
"""
)
)
- status.maintenance("Done writing influxdb credentials")
set_flag("autopkgtest.influx-creds-written")
@@ -658,10 +622,8 @@ def write_influx_creds():
"config.set.influxdb-context",
)
def unset_influx_creds():
- status.maintenance("Deleting influxdb credentials")
try:
os.unlink(os.path.expanduser("~ubuntu/influx.cred"))
except FileNotFoundError:
pass
- status.maintenance("Done deleting influxdb credentials")
clear_flag("autopkgtest.influx-creds-written")