← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] autopkgtest-cloud:clean-more-instances into autopkgtest-cloud:master

 

Brian Murray has proposed merging autopkgtest-cloud:clean-more-instances into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~ubuntu-release/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/463233

Some instance names now include the UUID of the test in the instance name e.g.:

adt-noble-i386-cmake-20240327-204734-juju-7f2275-prod-proposed-migration-environment-3
-72e5fc9e-715e-4b33-a503-a09d14dbcb33

However, cleanup-instances would never consider these for cleaning because the check for the hostname was using `instance.name.endswith()` which is now part of the UUID. Subsequently, we had quite a few stray instances in lcy02.

I've cowboy'ed this into production (on autopkgtest-cloud-worker 0 and 1) so that I could cleanup stale instances in production.
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of autopkgtest-cloud:clean-more-instances into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances
index 024ad93..5067f52 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/cleanup-instances
@@ -113,7 +113,7 @@ for instance in nova.servers.list():
     if not instance.name.startswith("adt-"):
         continue
 
-    if not instance.name.endswith("-" + our_hostname):
+    if our_hostname not in instance.name:
         logging.debug(
             "instance %s is managed by different worker, ignoring",
             instance.name,