← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:fix-killing-tests-api-version-parsing into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:fix-killing-tests-api-version-parsing into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)
Related bugs:
  Bug #2063429 in Auto Package Testing: "worker killing doesn't work with bos02"
  https://bugs.launchpad.net/auto-package-testing/+bug/2063429

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/464968
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:fix-killing-tests-api-version-parsing into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
index 646c189..15408fe 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -627,7 +627,15 @@ def cleanup_and_sleep(out_dir):
 
 
 def kill_openstack_server(test_uuid: str):
-    if int(os.environ.get("OS_IDENTITY_API_VERSION")) == 3:
+    # The OS_IDENTITY_API_VERSION isn't defined in the rcfiles for
+    # datacentres with openstack api version=2
+    # Since IS provides us with these files, modifying them to
+    # include this variable isn't the right approach.
+    # We should check for its presence, and subsequently check
+    # the value of the variable.
+    # If None, api version is 2
+    api_version = os.environ.get("OS_IDENTITY_API_VERSION")
+    if api_version is not None and int(api_version) == 3:
         auth = v3.Password(
             auth_url=os.environ["OS_AUTH_URL"],
             username=os.environ["OS_USERNAME"],