jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-48555] Add the possibility to enforce timeout (add forcible parameter)

Open
#450 0 comments 0 reactions 0 assignees View on GitHub
component:workflow-basic-steps-plugin imported-jira-issue pipeline priority:minor resolution:unresolved
Dominant language
Java
Stars
73
Forks
129
PR merge metrics
No merged PRs in 30d

Description

I have a java.util.concurrent.LinkedBlockingQueue() which holds every step for my build pipeline. I also have a variable count of workers that call a getWork() method to get one of those steps. getWork() looks like:

Step getWork() {

if (Data.stepQueue.size() == 0) {
return null
}

Step work
try {
timeout(time: 10, unit: 'SECONDS') {
work = Data.stepQueue.take()
}
} catch (e) {
echo "Pipeline Warning: Could not take new element of stepQueue. Worker may shut down now..."
return null
}

if (!work.readyToRun) {
Data.stepQueue.put(work)
return getWork()
}
return work
}


I put a timeout around the take() call, because there might not be enough work at the end. The issue is, that killing this takes much longer than it should.

I checked the source code and there is already a forcible attribute. It would be great to pass a value by calling timeout like this:

timeout(forcible: true, time: 10, unit: 'SECONDS') {

data.take()
}

Please add the possibility to enforce this.

---
Originally reported by ctwx, imported from: Add the possibility to enforce timeout (add forcible parameter)


  • status: Open
  • priority: Minor
  • component(s): workflow-basic-steps-plugin
  • label(s): pipeline, plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251215-220547

Raw content of original issue

I have a java.util.concurrent.LinkedBlockingQueue<Step>() which holds every step for my build pipeline. I also have a variable count of workers that call a getWork() method to get one of those steps. getWork() looks like:



Step getWork() {

if (Data.stepQueue.size() == 0) {
return null
}

Step work
try {
timeout(time: 10, unit: 'SECONDS') {
work = Data.stepQueue.take()
}
} catch (e) {
echo "Pipeline Warning: Could not take new element of stepQueue. Worker may shut down now..."
return null
}

if (!work.readyToRun) {
Data.stepQueue.put(work)
return getWork()
}
return work
}



I put a timeout around the take() call, because there might not be enough work at the end. The issue is, that killing this takes much longer than it should.

I checked the source code and there is already a forcible attribute. It would be great to pass a value by calling timeout like this:



timeout(forcible: true, time: 10, unit: 'SECONDS') {

data.take()
}


Please add the possibility to enforce this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.