Skip to content

Commit 294ad42

Browse files
authored
Merge pull request #1354 from jglick/KubernetesAgentErrorCondition-podTemplate
2 parents 1184bb0 + 4279756 commit 294ad42

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
3737
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
3838
import org.jenkinsci.plugins.workflow.graph.FlowNode;
39+
import org.jenkinsci.plugins.workflow.graph.StepNode;
3940
import org.jenkinsci.plugins.workflow.graphanalysis.LinearBlockHoppingScanner;
4041
import org.jenkinsci.plugins.workflow.steps.StepContext;
4142
import org.jenkinsci.plugins.workflow.support.steps.AgentErrorCondition;
@@ -91,6 +92,7 @@ public boolean test(Throwable t, StepContext context) throws IOException, Interr
9192
LOGGER.fine(() -> "Found origin " + origin + " " + origin.getDisplayFunctionName());
9293
LinearBlockHoppingScanner scanner = new LinearBlockHoppingScanner();
9394
scanner.setup(origin);
95+
boolean foundPodTemplate = false;
9496
for (FlowNode callStack : scanner) {
9597
WorkspaceAction ws = callStack.getPersistentAction(WorkspaceAction.class);
9698
if (ws != null) {
@@ -121,9 +123,15 @@ public boolean test(Throwable t, StepContext context) throws IOException, Interr
121123
LOGGER.fine(() -> "active on " + node + " (termination reasons: " + terminationReasons + ")");
122124
return true;
123125
}
126+
foundPodTemplate |= callStack instanceof StepNode && ((StepNode) callStack).getDescriptor() instanceof PodTemplateStep.DescriptorImpl;
124127
}
125128
if (!handleNonKubernetes) {
126-
listener.getLogger().println("Could not find a node block associated with " + origin.getDisplayFunctionName() + " (source of error)");
129+
if (foundPodTemplate) {
130+
listener.getLogger().println("Could not find a node block associated with " + origin.getDisplayFunctionName() + " (source of error) but inside podTemplate");
131+
return true;
132+
} else {
133+
listener.getLogger().println("Could not find a node block associated with " + origin.getDisplayFunctionName() + " (source of error)");
134+
}
127135
}
128136
return handleNonKubernetes;
129137
}

0 commit comments

Comments
 (0)