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

Proposed by Ryan Harper
Status: Merged
Approved by: Dan Watkins
Approved revision: aaf0c0e11ed07b65d15f8759d907483561c40334
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/cloud-tests-lxd-retry-delete
Merge into: cloud-init:master
Diff against target: 32 lines (+13/-1)
1 file modified
tests/cloud_tests/platforms/lxd/instance.py (+13/-1)
Reviewer Review Type Date Requested Status
Dan Watkins Approve
Server Team CI bot continuous-integration Approve
Paride Legovini Approve
Review via email: mp+374043@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Paride Legovini (paride) wrote :

LGTM

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

I need to add a sleep after the failure

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:c6bdca59c2b7afdf19b9bc7a4df8367584016627
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1206/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1206//rebuild

review: Needs Fixing (continuous-integration)
aaf0c0e... by Ryan Harper

Add the sleep before next retry.

Revision history for this message
Paride Legovini (paride) wrote :

Right. In the usual failure mode retrying should work even without sleeping, but it's way better to add a sleep(1) there.

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:aaf0c0e11ed07b65d15f8759d907483561c40334
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1207/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1207//rebuild

review: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tests/cloud_tests/platforms/lxd/instance.py b/tests/cloud_tests/platforms/lxd/instance.py
index 83c97ab..2b804a6 100644
--- a/tests/cloud_tests/platforms/lxd/instance.py
+++ b/tests/cloud_tests/platforms/lxd/instance.py
@@ -4,6 +4,7 @@
44
5import os5import os
6import shutil6import shutil
7import time
7from tempfile import mkdtemp8from tempfile import mkdtemp
89
9from cloudinit.util import load_yaml, subp, ProcessExecutionError, which10from cloudinit.util import load_yaml, subp, ProcessExecutionError, which
@@ -224,7 +225,18 @@ class LXDInstance(Instance):
224 LOG.debug("%s: deleting container.", self)225 LOG.debug("%s: deleting container.", self)
225 self.unfreeze()226 self.unfreeze()
226 self.shutdown()227 self.shutdown()
227 self.pylxd_container.delete(wait=True)228 retries = [1] * 5
229 for attempt, wait in enumerate(retries):
230 try:
231 self.pylxd_container.delete(wait=True)
232 break
233 except Exception:
234 if attempt + 1 >= len(retries):
235 raise
236 LOG.debug('Failed to delete container %s (%s/%s) retrying...',
237 self, attempt + 1, len(retries))
238 time.sleep(wait)
239
228 self._pylxd_container = None240 self._pylxd_container = None
229241
230 if self.platform.container_exists(self.name):242 if self.platform.container_exists(self.name):

Subscribers

People subscribed via source and target branches