Fix bug 2062: Ignore "model not found" exception when deleting models 80/12180/1
authorDavid Garcia <david.garcia@canonical.com>
Wed, 8 Jun 2022 09:16:54 +0000 (11:16 +0200)
committergarciadav <david.garcia@canonical.com>
Wed, 8 Jun 2022 09:18:10 +0000 (11:18 +0200)
Change-Id: Ife06b41bf2bcf32b080b405e607450d9303d19e0
Signed-off-by: David Garcia <david.garcia@canonical.com>
n2vc/libjuju.py

index 355a51e..5e4bef3 100644 (file)
@@ -1254,14 +1254,17 @@ class Libjuju:
             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(