Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-49707] retry without conditions should handle node removal #254

Merged
merged 6 commits into from
Jul 22, 2022

Conversation

jglick
Copy link
Member

@jglick jglick commented Jul 21, 2022

Downstream of jenkinsci/workflow-step-api-plugin#124, and jenkinsci/workflow-cps-plugin#570 to be effective.

jenkins-infra/helpdesk#3031 (comment) noted earlier in #180 (comment). If you have

retry(2) { // no conditions: […]
  node('remote') {
    sh 'work
  }
}

and the agent is removed, the block was surprisingly not retried. This is because actualInterruption defaults to true for compatibility in jenkinsci/workflow-step-api-plugin#51 and BodyExecution.cancel(CauseOfInterruption...) does not override that.

@jglick jglick requested a review from dwnusbaum July 21, 2022 21:49
@@ -287,7 +287,11 @@ public static final class QueueTaskCancelled extends CauseOfInterruption {
continue;
}
listener.getLogger().println("Agent " + node.getNodeName() + " was deleted; cancelling node body");
body.cancel(new RemovedNodeCause());
if (Util.isOverridden(BodyExecution.class, body.getClass(), "cancel", Throwable.class)) {
body.cancel(new FlowInterruptedException(Result.ABORTED, false, new RemovedNodeCause()));
Copy link
Member Author

Choose a reason for hiding this comment

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

Passing false here is the key aspect of the fix. It means that this was not some user clicking the red × on the build, and so retry should process it by default (even without use of conditions: [agent()]).

@jglick jglick marked this pull request as ready for review July 22, 2022 19:06
@jglick jglick enabled auto-merge July 22, 2022 19:07
@jglick jglick merged commit 02b9244 into jenkinsci:master Jul 22, 2022
@jglick jglick deleted the retry-unconditionally-JENKINS-49707 branch July 22, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants