← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~raharper/cloud-init:fix/cloud-tests-lxd-retry-delete into cloud-init:master


Ryan Harper has proposed merging ~raharper/cloud-init:fix/cloud-tests-lxd-retry-delete into cloud-init:master.

Commit message:
cloud_test/lxd: Retry container delete a few times

LXD integration tests fail sometimes due to failure to delete the
container, usually related to ZFS backend.  This is a transient
issue unrelated to the test itself.  Teach LXD platform to retry
this a few times before returning an error.

Requested reviews:
  cloud-init Commiters (cloud-init-dev)

For more details, see:
Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/cloud-tests-lxd-retry-delete into cloud-init:master.
diff --git a/tests/cloud_tests/platforms/lxd/instance.py b/tests/cloud_tests/platforms/lxd/instance.py
index 83c97ab..027c1dd 100644
--- a/tests/cloud_tests/platforms/lxd/instance.py
+++ b/tests/cloud_tests/platforms/lxd/instance.py
@@ -224,7 +224,17 @@ class LXDInstance(Instance):
         LOG.debug("%s: deleting container.", self)
-        self.pylxd_container.delete(wait=True)
+        retries = [1] * 5
+        for attempt, wait in enumerate(retries):
+            try:
+                self.pylxd_container.delete(wait=True)
+                break
+            except Exception:
+                if attempt + 1 >= len(retries):
+                    raise
+                LOG.debug('Failed to delete container %s (%s/%s) retrying...',
+                          self, attempt + 1, len(retries))
         self._pylxd_container = None
         if self.platform.container_exists(self.name):

Follow ups