summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2019-10-11 16:52:13 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-10-11 16:52:13 +0000
commit823708ea031290c864e3aef67f60f6eb495f281d (patch)
tree41cf1db3c061518021219fa781a440d46cbd0ad1
parent7d5d34f3643a2108d667759f57a5ab63d0affadd (diff)
downloadvyos-cloud-init-823708ea031290c864e3aef67f60f6eb495f281d.tar.gz
vyos-cloud-init-823708ea031290c864e3aef67f60f6eb495f281d.zip
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.
-rw-r--r--tests/cloud_tests/platforms/lxd/instance.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/cloud_tests/platforms/lxd/instance.py b/tests/cloud_tests/platforms/lxd/instance.py
index 83c97ab4..2b804a62 100644
--- a/tests/cloud_tests/platforms/lxd/instance.py
+++ b/tests/cloud_tests/platforms/lxd/instance.py
@@ -4,6 +4,7 @@
import os
import shutil
+import time
from tempfile import mkdtemp
from cloudinit.util import load_yaml, subp, ProcessExecutionError, which
@@ -224,7 +225,18 @@ class LXDInstance(Instance):
LOG.debug("%s: deleting container.", self)
self.unfreeze()
self.shutdown()
- 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))
+ time.sleep(wait)
+
self._pylxd_container = None
if self.platform.container_exists(self.name):