Skip to content

Commit

Permalink
Merge pull request #417 from jglick/StepExecution.acceptAll
Browse files Browse the repository at this point in the history
Using `StepExecution.acceptAll`
  • Loading branch information
jglick authored Jan 24, 2025
2 parents 109f3e7 + e803ce8 commit 1fcd4ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- TODO until in BOM: -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>686.v603d058a_e148</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,11 @@ private static class HandlerImpl extends Handler {

private void check(Computer c) {
String name = c.getName();
StepExecution.applyAll(Execution.class, exec -> {
StepExecution.acceptAll(Execution.class, exec -> {
if (exec.watching && exec.node.equals(name)) {
LOGGER.fine(() -> "Online/offline event on " + name + ", checking current status of " + exec.remote + " soon");
threadPool().schedule(exec::check, 15, TimeUnit.SECONDS);
}
return null;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void stop(@NonNull Throwable cause) throws Exception {
}
Set<StepContext> newAnomalous = new HashSet<>();
Set<String> affectedNodes = new HashSet<>();
StepExecution.applyAll(ExecutorStepExecution.class, exec -> {
StepExecution.acceptAll(ExecutorStepExecution.class, exec -> {
StepContext ctx = exec.getContext();
if (!knownTasks.contains(ctx)) {
LOGGER.warning(() -> "do not know about " + ctx);
Expand All @@ -351,11 +351,10 @@ public void stop(@NonNull Throwable cause) throws Exception {
} else {
LOGGER.fine(() -> "know about " + ctx);
}
return null;
}).get();
// Also abort any shell steps running on the same node(s):
if (!affectedNodes.isEmpty()) {
StepExecution.applyAll(DurableTaskStep.Execution.class, exec -> {
StepExecution.acceptAll(DurableTaskStep.Execution.class, exec -> {

Check warning on line 357 in src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 334-357 are not covered by tests
if (affectedNodes.contains(exec.node)) {
StepContext ctx = exec.getContext();
try {
Expand All @@ -365,7 +364,6 @@ public void stop(@NonNull Throwable cause) throws Exception {
}
ctx.onFailure(new FlowInterruptedException(Result.ABORTED, false, new RemovedNodeCause()));
}
return null;
});
}
for (StepContext ctx : newAnomalous) {
Expand Down

0 comments on commit 1fcd4ad

Please sign in to comment.