Skip to content

Commit 4d3fe6c

Browse files
committed
Use canStartBuild rather than nextBuild for starting
There is some evidence that a delay in nextBuild can leak to unrelated workers. Switch to canStartBuild, whose docs show an example to put the worker in “quarantine” and avoid the quarantine's exponential backoff mechanism.
1 parent 6ab531a commit 4d3fe6c

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

master/master.cfg

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,22 @@ def get_delay(now, end):
223223
def no_builds_between(start, end):
224224
start = datetime.strptime(start, "%H:%M").time()
225225
end = datetime.strptime(end, "%H:%M").time()
226-
def f(builder, requests):
226+
@defer.inlineCallbacks
227+
def canStartBuild(builder, wfb, request):
227228
now = datetime.now().time()
228229
if is_within_time_range(now, start, end):
229230
delay = get_delay(now, end)
230-
# Schedule the build later
231-
deferred = defer.Deferred()
232-
builder.master.reactor.callLater(
233-
int(delay),
234-
deferred.callback,
235-
requests[0],
236-
)
237-
return deferred
231+
# Adapted from: https://docs.buildbot.net/current/manual/customization.html#canstartbuild-functions
232+
wfb.worker.quarantine_timeout = delay
233+
wfb.worker.putInQuarantine()
234+
# This does not take the worker out of quarantine, it only resets
235+
# the timeout value to default (restarting the default
236+
# exponential backoff)
237+
wfb.worker.resetQuarantine()
238+
return False
238239
# Schedule the build now
239-
return requests[0]
240-
return f
240+
return True
241+
return canStartBuild
241242

242243

243244
github_status_builders = []
@@ -323,7 +324,7 @@ for branch_num, (git_url, branchname, git_branch) in enumerate(git_branches):
323324
# This worker runs pyperformance at 12am. If a build is scheduled between
324325
# 10pm and 2am, it will be delayed at 2am.
325326
if worker_name == "diegorusso-aarch64-bigmem":
326-
builder.nextBuild = no_builds_between("22:00", "2:00")
327+
builder.canStartBuild = no_builds_between("22:00", "2:00")
327328

328329
c["builders"].append(builder)
329330

@@ -392,7 +393,7 @@ for name, worker_name, buildfactory, stability, tier in BUILDERS:
392393
# This worker runs pyperformance at 12am. If a build is scheduled between
393394
# 10pm and 2am, it will be delayed at 2am.
394395
if worker_name == "diegorusso-aarch64-bigmem":
395-
builder.nextBuild = no_builds_between("22:00", "2:00")
396+
builder.canStartBuild = no_builds_between("22:00", "2:00")
396397

397398
c["builders"].append(builder)
398399

0 commit comments

Comments
 (0)