Skip to content

Commit

Permalink
Merge pull request #1354 from jglick/KubernetesAgentErrorCondition-po…
Browse files Browse the repository at this point in the history
…dTemplate
  • Loading branch information
Vlatombe authored Apr 15, 2023
2 parents 1184bb0 + 4279756 commit 294ad42
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepNode;
import org.jenkinsci.plugins.workflow.graphanalysis.LinearBlockHoppingScanner;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.support.steps.AgentErrorCondition;
Expand Down Expand Up @@ -91,6 +92,7 @@ public boolean test(Throwable t, StepContext context) throws IOException, Interr
LOGGER.fine(() -> "Found origin " + origin + " " + origin.getDisplayFunctionName());
LinearBlockHoppingScanner scanner = new LinearBlockHoppingScanner();
scanner.setup(origin);
boolean foundPodTemplate = false;
for (FlowNode callStack : scanner) {
WorkspaceAction ws = callStack.getPersistentAction(WorkspaceAction.class);
if (ws != null) {
Expand Down Expand Up @@ -121,9 +123,15 @@ public boolean test(Throwable t, StepContext context) throws IOException, Interr
LOGGER.fine(() -> "active on " + node + " (termination reasons: " + terminationReasons + ")");
return true;
}
foundPodTemplate |= callStack instanceof StepNode && ((StepNode) callStack).getDescriptor() instanceof PodTemplateStep.DescriptorImpl;
}
if (!handleNonKubernetes) {
listener.getLogger().println("Could not find a node block associated with " + origin.getDisplayFunctionName() + " (source of error)");
if (foundPodTemplate) {
listener.getLogger().println("Could not find a node block associated with " + origin.getDisplayFunctionName() + " (source of error) but inside podTemplate");
return true;
} else {
listener.getLogger().println("Could not find a node block associated with " + origin.getDisplayFunctionName() + " (source of error)");
}
}
return handleNonKubernetes;
}
Expand Down

0 comments on commit 294ad42

Please sign in to comment.