← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:lxd-armhf-kill-openstack-server-traceback into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:lxd-armhf-kill-openstack-server-traceback into autopkgtest-cloud:master.

Commit message:
fix: worker: don't try to kill openstack servers on the lxd-worker

This commit fixes a big which was causing the following traceback on the
lxd worker:
 Traceback (most recent call last):
   File "/home/ubuntu/autopkgtest-cloud/worker/worker", line 1716, in <module>
     main()
   File "/home/ubuntu/autopkgtest-cloud/worker/worker", line 1709, in main
     queue.wait()
   File "/usr/lib/python3/dist-packages/amqplib/client_0_8/abstract_channel.py", line 97, in wait
     return self.dispatch_method(method_sig, args, content)
   File "/usr/lib/python3/dist-packages/amqplib/client_0_8/abstract_channel.py", line 117, in dispatch_me>
     return amqp_method(self, args, content)
   File "/usr/lib/python3/dist-packages/amqplib/client_0_8/channel.py", line 2060, in _basic_deliver
     func(msg)
   File "/home/ubuntu/autopkgtest-cloud/worker/worker", line 1360, in request
     kill_openstack_server(test_uuid)
   File "/home/ubuntu/autopkgtest-cloud/worker/worker", line 647, in kill_openstack_server
     auth_url=os.environ["OS_AUTH_URL"],
   File "/usr/lib/python3.8/os.py", line 675, in __getitem__
     raise KeyError(key) from None
 KeyError: 'OS_AUTH_URL'

This is fixed by first checking to see if the
/home/ubuntu/worker-lxd-armhf.conf file is present, and if it is, doing
nothing in the kill_openstack_server function.

This commit also moves some logging surrounding the
kill_openstack_server function into the function itself, to avoid
duplication of code.

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

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/467534

This commit fixes a bug I noticed on the lxd workers today. It's pertinent we fix it so we stop getting tracebacks and properly handle queue messages.

The fix itself it quite simple - just adding in a small check to see whether we're on the lxd worker or not, by checking for the lxd worker conf file.

This commit also moves some logging that was previously around the kill_openstack_server function into the function itself, to avoid code duplication.
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:lxd-armhf-kill-openstack-server-traceback 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 6957c0b..0ee1b10 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -633,6 +633,16 @@ def kill_openstack_server(test_uuid: str):
     # include this variable isn't the right approach.
     # So we check as a string instead, so OS_IDENTITY_API_VERSION=None
     # will fall to the else statement below
+    # First of all, we have to check we're not on the lxd worker
+    if os.path.exists("/home/ubuntu/worker-lxd-armhf.conf"):
+        # a log line isn't required here - we don't need to know there's
+        # no openstack server to kill, we already know we're on the lx
+        # worker
+        return
+    logging.info(
+        "Killing openstack server with uuid %s",
+        test_uuid,
+    )
     if os.environ.get("OS_IDENTITY_API_VERSION") == "3":
         auth = v3.Password(
             auth_url=os.environ["OS_AUTH_URL"],
@@ -1353,10 +1363,6 @@ def request(msg):
                             True,
                             release,
                         )
-                        logging.info(
-                            "Killing openstack server with uuid %s",
-                            test_uuid,
-                        )
                         kill_openstack_server(test_uuid)
                         cleanup_and_sleep(out_dir)
                 else:
@@ -1384,10 +1390,6 @@ def request(msg):
                             body.encode(),
                         )
                         msg.channel.basic_ack(msg.delivery_tag)
-                    logging.info(
-                        "Killing openstack server with uuid %s",
-                        test_uuid,
-                    )
                     kill_openstack_server(test_uuid)
                     # return here so the worker can go back to listening for
                     # test requests