jenkinsci / jenkinsci/workflow-basic-steps-plugin
[JENKINS-48555] Add the possibility to enforce timeout (add forcible parameter)
- 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)
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
Assessment
This issue has not been assessed yet.