Skip to content
Permalink
Browse files
Fix locking for freestyle jobs
Freestyle jobs did not hold the resource locks properly,
as they did not record the queueProjectName to the queue.
Any blocked jobs would give up waiting after QUEUE_TIMEOUT
seconds in the queue, even if there was a job blocking.

Fixes: JENKINS-47754
  • Loading branch information
Aga303 committed Oct 31, 2017
1 parent 3a9e649 commit c20d996d8534470070fb9189646ff55b903ec6f6
@@ -158,12 +158,13 @@ public LockableResource fromName(String resourceName) {
}

public synchronized boolean queue(List<LockableResource> resources,
long queueItemId) {
long queueItemId, String queueProjectName) {
for (LockableResource r : resources)
if (r.isReserved() || r.isQueued(queueItemId) || r.isLocked())
return false;
for (LockableResource r : resources)
r.setQueued(queueItemId);
for (LockableResource r : resources) {
r.setQueued(queueItemId, queueProjectName);
}
return true;
}

@@ -140,7 +140,7 @@ public CauseOfBlockage canRun(Queue.Item item) {
}

} else {
if (LockableResourcesManager.get().queue(resources.required, item.getId())) {
if (LockableResourcesManager.get().queue(resources.required, item.getId(), project.getFullDisplayName())) {
LOGGER.finest(project.getName() + " reserved resources " + resources.required);
return null;
} else {

0 comments on commit c20d996

Please sign in to comment.