fix: send Mattermost report before mirroring to avoid long delays
This commit is contained in:
@@ -354,7 +354,6 @@ def main() -> None:
|
|||||||
logger.info("Found %d unique image references", len(all_images))
|
logger.info("Found %d unique image references", len(all_images))
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
mirrored = []
|
|
||||||
|
|
||||||
for ref, img in all_images.items():
|
for ref, img in all_images.items():
|
||||||
entry = {
|
entry = {
|
||||||
@@ -385,18 +384,10 @@ def main() -> None:
|
|||||||
except InvalidVersion:
|
except InvalidVersion:
|
||||||
entry["status"] = "current" if img.tag == latest else "outdated"
|
entry["status"] = "current" if img.tag == latest else "outdated"
|
||||||
|
|
||||||
if do_mirror and entry["status"] == "outdated" and entry["latest"]:
|
|
||||||
new_ref = ref.rsplit(":", 1)[0] + ":" + entry["latest"]
|
|
||||||
if mirror_to_local(new_ref, local_registry):
|
|
||||||
mirrored.append(new_ref)
|
|
||||||
|
|
||||||
results.append(entry)
|
results.append(entry)
|
||||||
|
|
||||||
|
# Send report immediately after version checks, before mirroring
|
||||||
report = build_report(results)
|
report = build_report(results)
|
||||||
|
|
||||||
if mirrored:
|
|
||||||
report += f"\n\n*Mirrored {len(mirrored)} updated images to `{local_registry}`*"
|
|
||||||
|
|
||||||
logger.info("Sending Mattermost notification …")
|
logger.info("Sending Mattermost notification …")
|
||||||
send_mattermost(report, webhook_url)
|
send_mattermost(report, webhook_url)
|
||||||
logger.info("Done. %d outdated, %d floating, %d current, %d skipped",
|
logger.info("Done. %d outdated, %d floating, %d current, %d skipped",
|
||||||
@@ -405,6 +396,18 @@ def main() -> None:
|
|||||||
sum(1 for r in results if r["status"] == "current"),
|
sum(1 for r in results if r["status"] == "current"),
|
||||||
sum(1 for r in results if r["status"] == "skipped"))
|
sum(1 for r in results if r["status"] == "skipped"))
|
||||||
|
|
||||||
|
# Mirror outdated images after report is sent
|
||||||
|
if do_mirror:
|
||||||
|
mirrored = []
|
||||||
|
for entry in results:
|
||||||
|
if entry["status"] == "outdated" and entry["latest"]:
|
||||||
|
ref = entry["image"]
|
||||||
|
new_ref = ref.rsplit(":", 1)[0] + ":" + entry["latest"]
|
||||||
|
if mirror_to_local(new_ref, local_registry):
|
||||||
|
mirrored.append(new_ref)
|
||||||
|
if mirrored:
|
||||||
|
logger.info("Mirrored %d updated images to %s", len(mirrored), local_registry)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user