Skip to content

Commit 76a8827

Browse files
authored
Merge pull request #6472 from opsmill/pog-trigger-more-time
Use lock when configuring action triggers
2 parents 97eed9e + e775737 commit 76a8827

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

backend/infrahub/actions/tasks.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from prefect import flow
55
from prefect.client.orchestration import get_client
66

7+
from infrahub import lock
78
from infrahub.context import InfrahubContext # noqa: TC001 needed for prefect flow
89
from infrahub.services import InfrahubServices # noqa: TC001 needed for prefect flow
910
from infrahub.trigger.models import TriggerType
@@ -100,14 +101,14 @@ async def run_generator_group_event(
100101
async def configure_action_rules(
101102
service: InfrahubServices,
102103
) -> None:
103-
triggers = await gather_trigger_action_rules(db=service.database)
104-
105-
async with get_client(sync_client=False) as prefect_client:
106-
await setup_triggers(
107-
client=prefect_client,
108-
triggers=triggers,
109-
trigger_type=TriggerType.ACTION_TRIGGER_RULE,
110-
) # type: ignore[misc]
104+
async with lock.registry.get(name="configure-action-rules", namespace="trigger-rules", local=False):
105+
triggers = await gather_trigger_action_rules(db=service.database)
106+
async with get_client(sync_client=False) as prefect_client:
107+
await setup_triggers(
108+
client=prefect_client,
109+
triggers=triggers,
110+
trigger_type=TriggerType.ACTION_TRIGGER_RULE,
111+
) # type: ignore[misc]
111112

112113

113114
async def _run_generator(

0 commit comments

Comments
 (0)