diff --git a/tests/integration/tests/test_util/harness/lxd.py b/tests/integration/tests/test_util/harness/lxd.py index 685aa23ac..450ffa978 100644 --- a/tests/integration/tests/test_util/harness/lxd.py +++ b/tests/integration/tests/test_util/harness/lxd.py @@ -228,9 +228,14 @@ def delete_instance(self, instance_id: str): raise HarnessError(f"unknown instance {instance_id}") try: - run(["lxc", "rm", instance_id, "--force", "--debug"]) + # There are cases where the instance is not deleted properly and this command is stuck. + # A timeout prevents this. + run(["lxc", "rm", instance_id, "--force", "--debug"], timeout=60*5) except subprocess.CalledProcessError as e: raise HarnessError(f"failed to delete instance {instance_id}") from e + except subprocess.TimeoutExpired as e: + LOG.warning("LXC container removal timed out.") + pass self.instances.discard(instance_id)