Skip to content

Commit 5830d50

Browse files
Use claimed time for obsolete request cutoff
CancelOlderSameBranchRequests previously used the current buildset submitted_at as the cutoff for deciding which matching buildrequests were older. That is too early for tarball-docker: the newer tarball buildrequest may be queued while the previous tarball is still finishing and triggering downstream buildsets. Those downstream requests can then be submitted after the newer tarball request was queued, so only the subset submitted before that queued timestamp gets cancelled. Use the current buildrequest claimed_at instead. By the time tarball-docker is running this step, Buildbot has already claimed the buildrequest to create/run the build, so claimed_at is expected to be present and marks the point where the newer tarball actually started being handled by a master. For candidates, use br.get('submitted_at') from the buildrequest data returned by the /buildrequests query. Buildbot exposes buildrequest claimed_at and submitted_at as the same DateTime type, while buildset submitted_at is converted to an integer epoch value by the buildsets data API. Comparing buildrequest timestamps avoids extra type conversion and avoids mixing the two API representations. The buildset lookup remains only for sourcestamps used by the branch/repository/codebase/revision match.
1 parent 78d1768 commit 5830d50

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,16 +1001,22 @@ def run(self):
10011001
current_buildrequest = yield self.master.data.get(
10021002
("buildrequests", current_buildrequestid)
10031003
)
1004+
current_claimed_at = current_buildrequest.get("claimed_at")
10041005
current_buildsetid = current_buildrequest["buildsetid"]
10051006

10061007
current_buildset = yield self.master.data.get(("buildsets", current_buildsetid))
10071008
current_submitted_at = current_buildset.get("submitted_at")
10081009
current_sourcestamps = current_buildset.get("sourcestamps", [])
10091010

1010-
if current_submitted_at is None or not current_sourcestamps:
1011+
if (
1012+
current_claimed_at is None
1013+
or current_submitted_at is None
1014+
or not current_sourcestamps
1015+
):
10111016
self.addCompleteLog(
10121017
"summary",
1013-
"Current buildset is missing submitted_at or sourcestamps; nothing to do.\n",
1018+
"Current buildrequest is missing claimed_at or current buildset "
1019+
"is missing submitted_at or sourcestamps; nothing to do.\n",
10141020
)
10151021
return SUCCESS
10161022

@@ -1046,6 +1052,7 @@ def run(self):
10461052
lines.append(f" builderid={current_builderid}")
10471053
lines.append(f" buildername={current_buildername!r}")
10481054
lines.append(f" buildsetid={current_buildsetid}")
1055+
lines.append(f" claimed_at={current_claimed_at}")
10491056
lines.append(f" submitted_at={current_submitted_at}")
10501057
current_url = self._buildrequest_url(current_buildrequestid)
10511058
if current_url:
@@ -1072,14 +1079,14 @@ def run(self):
10721079

10731080
other_buildsetid = br["buildsetid"]
10741081
other_buildset = yield self.master.data.get(("buildsets", other_buildsetid))
1075-
other_submitted_at = other_buildset.get("submitted_at")
1082+
other_submitted_at = br.get("submitted_at")
10761083
other_sourcestamps = other_buildset.get("sourcestamps", [])
10771084

10781085
if other_submitted_at is None:
10791086
continue
10801087

1081-
# Newest wins: only cancel OLDER matching requests
1082-
if other_submitted_at >= current_submitted_at:
1088+
# Newest wins: only cancel requests created before this request was claimed.
1089+
if other_submitted_at >= current_claimed_at:
10831090
continue
10841091

10851092
# A match means same branch+repository+codebase but different revision

0 commit comments

Comments
 (0)