-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5737 from opsmill/lgu-migrate-req-art-def-check
Migrate RequestArtifactDefinitionCheck to prefect
- Loading branch information
Showing
18 changed files
with
244 additions
and
349 deletions.
There are no files selected for viewing
Empty file.
6 changes: 2 additions & 4 deletions
6
...age_bus/messages/check_artifact_create.py → backend/infrahub/artifacts/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import asyncio | ||
from typing import Any, Coroutine | ||
|
||
from infrahub_sdk.node import InfrahubNode | ||
|
||
from infrahub.core.constants import ValidatorConclusion, ValidatorState | ||
from infrahub.core.timestamp import Timestamp | ||
|
||
|
||
async def run_checks_and_update_validator( | ||
checks: list[Coroutine[Any, None, ValidatorConclusion]], validator: InfrahubNode | ||
) -> None: | ||
""" | ||
Execute a list of checks coroutines, and set validator fields accordingly. | ||
Tasks are retrieved by completion order so as soon as we detect a failing check, | ||
we set validator conclusion to failure. | ||
""" | ||
|
||
# First set validator to in progress, then wait for results | ||
validator.state.value = ValidatorState.IN_PROGRESS.value | ||
validator.started_at.value = Timestamp().to_string() | ||
validator.completed_at.value = "" | ||
await validator.save() | ||
|
||
for earliest_task in asyncio.as_completed(checks): | ||
result = await earliest_task | ||
if validator.conclusion.value != ValidatorConclusion.FAILURE.value and result == ValidatorConclusion.FAILURE: | ||
validator.conclusion.value = ValidatorConclusion.FAILURE.value | ||
await validator.save() | ||
# Continue to iterate to wait for the end of all checks | ||
|
||
validator.state.value = ValidatorState.COMPLETED.value | ||
validator.completed_at.value = Timestamp().to_string() | ||
if validator.conclusion.value != ValidatorConclusion.FAILURE.value: | ||
validator.conclusion.value = ValidatorConclusion.SUCCESS.value | ||
|
||
await validator.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
backend/infrahub/message_bus/messages/request_artifactdefinition_check.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from . import artifact, generator, repository | ||
from . import generator, repository | ||
|
||
__all__ = ["artifact", "generator", "repository"] | ||
__all__ = ["generator", "repository"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.