Skip to content

Commit

Permalink
Error-handling around the scan backlog runner loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Oct 18, 2024
1 parent c05e718 commit 29d9a5f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion skydriver/k8s/scan_backlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,27 @@ async def run(
mongo_client: AsyncIOMotorClient, # type: ignore[valid-type]
k8s_batch_api: kubernetes.client.BatchV1Api,
) -> None:
"""The main loop."""
"""Error-handling around the scan backlog runner loop."""
LOGGER.info("Started scan backlog runner.")

while True:
# let's go!
try:
await _run(mongo_client, k8s_batch_api)
except Exception as e:
LOGGER.exception(e)

# wait hopefully log enough that any transient errors are resolved,
# like a mongo pod failure and restart
await asyncio.sleep(ENV.SCAN_BACKLOG_RUNNER_DELAY)
LOGGER.info("Restarted scan backlog runner.")


async def _run(
mongo_client: AsyncIOMotorClient, # type: ignore[valid-type]
k8s_batch_api: kubernetes.client.BatchV1Api,
) -> None:
"""The (actual) main loop."""
manifests = database.interface.ManifestClient(mongo_client)
scan_backlog = database.interface.ScanBacklogClient(mongo_client)

Expand Down

0 comments on commit 29d9a5f

Please sign in to comment.