Fix bug 2060: Ignore "model not found" exception when deleting models
Change-Id: Ife06b41bf2bcf32b080b405e607450d9303d19e0
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/n2vc/libjuju.py b/n2vc/libjuju.py
index 4ee0abf..7492acc 100644
--- a/n2vc/libjuju.py
+++ b/n2vc/libjuju.py
@@ -1422,14 +1422,17 @@
self.log.info(f"Model {model_name} deleted forcefully")
try:
- await asyncio.wait_for(
- _destroy_model_gracefully(model_name, controller), timeout=120
- )
- except asyncio.TimeoutError:
- await _destroy_model_forcefully(model_name, controller)
+ try:
+ await asyncio.wait_for(
+ _destroy_model_gracefully(model_name, controller), timeout=120
+ )
+ except asyncio.TimeoutError:
+ await _destroy_model_forcefully(model_name, controller)
except juju.errors.JujuError as e:
if any("has been removed" in error for error in e.errors):
return
+ if any("model not found" in error for error in e.errors):
+ return
raise e
async def destroy_application(