Skip to content

Commit 4c7c0ab

Browse files
authored
Merge pull request #7495 from opsmill/pog-catch-missing-automation
Log for automation already deleted
2 parents f094308 + acca9de commit 4c7c0ab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

backend/infrahub/trigger/setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from prefect.client.orchestration import PrefectClient, get_client
77
from prefect.client.schemas.filters import DeploymentFilter, DeploymentFilterName
88
from prefect.events.schemas.automations import Automation
9+
from prefect.exceptions import PrefectHTTPStatusError
910

1011
from infrahub import lock
1112
from infrahub.database import InfrahubDatabase
@@ -133,8 +134,14 @@ async def setup_triggers(
133134
continue
134135

135136
report.deleted.append(existing_automation)
136-
await client.delete_automation(automation_id=existing_automation.id)
137-
log.info(f"{item_to_delete} Deleted")
137+
try:
138+
await client.delete_automation(automation_id=existing_automation.id)
139+
log.info(f"{item_to_delete} Deleted")
140+
except PrefectHTTPStatusError as exc:
141+
if exc.response.status_code == 404:
142+
log.info(f"{item_to_delete} was already deleted")
143+
else:
144+
raise
138145

139146
if trigger_type:
140147
log.info(

0 commit comments

Comments
 (0)