In case the timeout occurs, and Jenkins is restarted during the grace period if waits for the inner block to terminate, then the build hangs forever with this exception in the Jenkins log:
Mär 10, 2017 3 {noformat} 2020-03-13 02 : 49 09 : 10 PM org 40 . jenkinsci 575+0000 [id=1502] WARNING o . plugins j . workflow p . flow w . f. FlowExecutionList$ItemListenerImpl$1 # onFailure WARNUNG : Failed to load CpsFlowExecution[Owner[ hang devops-gate / 1 master/blackbox-self-service/25907 : hang devops-gate/master/blackbox-self-service # 1 25907 ]] java.lang.NullPointerException at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.cancel(TimeoutStepExecution.java: 94 151 ) at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.setupTimer(TimeoutStepExecution.java: 88 139 ) at org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution.onResume(TimeoutStepExecution.java: 57 90 ) at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl$1.onSuccess(FlowExecutionList.java:185) at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl$1.onSuccess(FlowExecutionList.java:180) ... {noformat}
Reproducability of this issue relies on a block that does not immediately Exit. For example:
{code} node \ { timeout (time: 10, unit: 'SECONDS') \ { build job: 'hang2', parameters: [ new StringParameterValue('A','B') ], quietPeriod: 0 }} {code} with a second Pipeline Job hang2:
{code} retry(3) \ { sleep 300 } {code} Creates this console log:
{noformat} Gestartet durch Benutzer RK [Pipeline] node Running on host in /$JENKINS_HOME/workspace/hang [Pipeline] \ { [Pipeline] timeout Timeout set to expire in 10 Sekunden [Pipeline] \ { [Pipeline] build (Building hang2) Scheduling project: hang2 Starting building: hang2 #1 Cancelling nested steps due to timeout Resuming build at Fri Mar 10 15:49:00 CET 2017 after Jenkins restart Waiting to resume hang #1|: ??? Waiting to resume hang #1|: host ist offline Waiting to resume hang #1|: host ist offline
Ready to run at Fri Mar 10 15:49:10 CET 2017
Timeout expired 3,7 Sekunden ago {noformat} ... and then it hangs forever.
Reason: when onResume() is called, the timer is expired, so cancel() is called, and since it already tried to cancel, forcible is true, and then killer is null, causing an NPE.
Fix: Check killer for null on line 94 in cancel() in TimeoutStepExecution().
Rationale for Major, not minor bug: breaks restart resiliense. |
|
|