-
Bug
-
Resolution: Duplicate
-
Major
-
None
-
Jenkins v2.44
Kubernetes Plugin v0.10
Openshift v1.3.0
Creating multiple podTemplates with different labels allows you to create pods in parallel.
However the plugin treats all podTemplates in a Run as nested even when they are not. Every podTemplate in the pipeline effectively inherits from previously declared templates.
Consider the following pipeline.
stage ('Compile') { podTemplate(label: 'node-0', containers: [containerTemplate(name: 'maven', ...)]) { node('node-0') { container('maven') { sleep(1) } } } } stage ('Tests') { parallel ( "A": { podTemplate(label: 'node-a', containers: [containerTemplate(name: 'maven', ...)])) { node('node-a') { container('maven') { sleep (15) } } } }, "B": { podTemplate(label: 'node-b', containers: [containerTemplate(name: 'maven', ...)])) { node('node-b') { container('maven') { sleep (15) } } } } ) }
This creates a template for node-a that inherits from node-0 and a template for node-b that inherits from both node-a and node-0. Keep adding pod templates and they keep nesting in weird ways.
Depending on the nesting rules and the names used on each template some containers get created while others don't. The behaviour becomes quite erratic. e.g. I'm seeing the HOME var of one container being set to the start-up command of another (HOME='/bin/sh -c').
In any case the intention of the pipeline developer here clearly isn't to nest templates.
The hacky workaround to stop this is to clear all previously stacked template names from the Run before creating a new template.
Call this function before any occurrence of podTemplate:
@NonCPS
def clearTemplateNames() {
def r = script.currentBuild.rawBuild
def action = r.getAction(PodTemplateAction.class);
if(action)
}
- duplicates
-
JENKINS-50196 Jenkins Kubernetes plugin - Running a sequence of podTemplate with inheritFrom
- Resolved
- is duplicated by
-
JENKINS-47499 Parallel Nested Pods
- Closed
-
JENKINS-46450 Since 0.12, pod templates got inherited even if not nested
- Closed
- is related to
-
JENKINS-39801 Waiting for next available executor
- Resolved
-
JENKINS-53683 Parallel pod-provisioning fails for distinct pod templates
- Closed