Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ private void cancel() {
listener().getLogger().println("Cancelling nested steps due to timeout");
body.cancel(new ExceededTimeout());
forcible = true;
long now = System.currentTimeMillis();
end = now + GRACE_PERIOD;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the previous code would set end = now + GRACE_PERIOD, and then the call to resetTimer would set end = now + timeout, so this was effectively dead code and the grace period was the timeout.

timeout = GRACE_PERIOD;
resetTimer();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable.Row;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import org.junit.*;

import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertEquals;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.BuildWatcher;
Expand Down Expand Up @@ -330,7 +332,7 @@ private Execution(StepContext context) {
getContext().get(TaskListener.class).getLogger().println("ignoring " + cause);
}
}
@TestExtension("unresponsiveBody") public static class DescriptorImpl extends StepDescriptor {
@TestExtension({"unresponsiveBody", "gracePeriod"}) public static class DescriptorImpl extends StepDescriptor {
@Override public String getFunctionName() {
return "unkillable";
}
Expand Down Expand Up @@ -366,4 +368,16 @@ private Execution(StepContext context) {
}
});
}

@Issue("JENKINS-54607")
@Test public void gracePeriod() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("timeout(time: 15, unit: 'SECONDS') {unkillable()}", true));
story.j.assertBuildStatus(Result.ABORTED, p.scheduleBuild2(0).get());
assertThat(p.getLastBuild().getDuration(), lessThan(29_000L)); // 29 seconds
}
});
}
}