Blob Blame History Raw
From a1494e66aa61334ad2bb9b79e8989a94c100b165 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Jul 07 2021 22:22:24 +0000
Subject: also nudge reused components after 10 minutes


---

diff --git a/module_build_service/scheduler/producer.py b/module_build_service/scheduler/producer.py
index bdf1ae0..b6f08f4 100644
--- a/module_build_service/scheduler/producer.py
+++ b/module_build_service/scheduler/producer.py
@@ -105,6 +105,7 @@ def fail_lost_builds():
     # TODO re-use
 
     if conf.system == "koji":
+        ten_minutes = timedelta(minutes=10)
         # We don't do this on behalf of users
         koji_session = get_session(conf, login=False)
         log.info("Querying tasks for statuses:")
@@ -119,15 +120,17 @@ def fail_lost_builds():
             if not component_build.task_id:
                 continue
 
-            # Don't check tasks for components which have been reused,
-            # they may have BUILDING state temporarily before we tag them
-            # to new module tag. Checking them would be waste of resources.
+            # For components which have been reused, wait 10 minutes before checking.
+            # They may be in BUILDING state temporarily before we tag them
+            # to new module tag. Checking them at that point would be waste of resources.
             if component_build.reused_component_id:
-                log.debug(
-                    'Skipping check for task "%s", the component has been reused ("%s").',
-                    component_build.task_id, component_build.reused_component_id
-                )
-                continue
+                now = datetime.utcnow()
+                if (now - component_build.module_build.time_modified) < ten_minutes:
+                    log.debug(
+                        'Skipping check for task "%s", the component has been reused ("%s").',
+                        component_build.task_id, component_build.reused_component_id
+                    )
+                    continue
 
             task_id = component_build.task_id
 
@@ -165,6 +168,7 @@ def fail_lost_builds():
                     build_name=component_build.package,
                     build_release=build_release,
                     build_version=build_version,
+                    module_build_id=component_build.module_build.id,
                 )
 
     elif conf.system == "mock":