-
Bug
-
Resolution: Unresolved
-
Minor
-
None
kubernetes plugin version: 1.17.2
When I run a podTemplate nested, it inherit the containers of the upper level podTemplate. It is a weird behaviour is better to explain it with an example
Code:
podTemplate(showRawYaml: true, label: "alpine1", cloud: "Build farm", containers: [ containerTemplate(name: 'alpine', image: 'alpine', ttyEnabled: true, command: "cat")]) { node ("alpine1") { container('alpine') { sh 'whoami' podTemplate(showRawYaml: true, label: "golang", cloud: "Build farm", containers: [ containerTemplate(name: 'golang', image: 'golang', ttyEnabled: true, command: "cat")]) { node ("golang") { container('golang') { sh 'sleep 120' } } } } } }
Expected
- alpine pod template containers: {jnlp} {alpine}
- golang pod template containers: {jnlp} {golang}
What I have:
- alpine pod template containers: {jnlp} {alpine}
- golang pod template containers: {jnlp} {golang} {alpine}
Log(removed env variables):
Still waiting to schedule task Waiting for next available executor on 'alpine1-dgpx2-5jp6k' Agent alpine1-prfs1-ghwvg is provisioned from template Kubernetes Pod Template --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "https://..." labels: jenkins: "slave" jenkins/alpine1: "true" name: "alpine1-prfs1-ghwvg" spec: containers: - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "alpine" imagePullPolicy: "IfNotPresent" name: "alpine" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - env: - name: "JENKINS_SECRET" ... image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes: - emptyDir: {} name: "workspace-volume" Running on alpine1-prfs1-ghwvg in /home/jenkins/workspace/CII_test_pod_template_nest [Pipeline] { [Pipeline] container [Pipeline] { [Pipeline] sh + whoami root [Pipeline] podTemplate [Pipeline] { [Pipeline] node Still waiting to schedule task 'golang-t6g4f-4tzqr' is offline Agent golang-t6g4f-4tzqr is provisioned from template Kubernetes Pod Template --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "https://..." labels: jenkins: "slave" jenkins/golang: "true" name: "golang-t6g4f-4tzqr" spec: containers: - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "alpine" imagePullPolicy: "IfNotPresent" name: "alpine" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "golang" imagePullPolicy: "IfNotPresent" name: "golang" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - env: - name: "JENKINS_SECRET" ... image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes: - emptyDir: {} name: "workspace-volume" Running on golang-t6g4f-4tzqr in /home/jenkins/workspace/CII_test_pod_template_nest [Pipeline] { [Pipeline] container [Pipeline] { [Pipeline] sh + sleep 120
[JENKINS-58709] Nested pod templates inherit container of upper level pod
Description |
Original:
kubernetes plugin version: 1.17.2 When I run a podTemplate nested, it inherit the containers of the upper level podTemplate. It is a weird behaviour is better to explain it with an example Code: {code:java} podTemplate(showRawYaml: true, label: "alpine1", cloud: "Build farm", containers: [ containerTemplate(name: 'alpine', image: 'alpine', ttyEnabled: true, command: "cat")]) { node ("alpine1") { container('alpine') { sh 'whoami' podTemplate(showRawYaml: true, label: "golang", cloud: "Build farm", containers: [ containerTemplate(name: 'golang', image: 'golang', ttyEnabled: true, command: "cat")]) { node ("golang") { container('golang') { sh 'sleep 120' } } } } } } {code} Expected * alpine pod template containers: \{jnlp} \{alpine} * golang pod template containers: \{jnlp} \{golang} What I have: * alpine pod template containers: \{jnlp} \{alpine} * golang pod template containers: \{jnlp} \{golang} \{alpine} Log(removed env variables): {code:java} Still waiting to schedule task Waiting for next available executor on 'alpine1-dgpx2-5jp6k' Agent alpine1-prfs1-ghwvg is provisioned from template Kubernetes Pod Template --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "https://callisto.dev.youview.co.uk/job/CII_test_pod_template_nest/13/" labels: jenkins: "slave" jenkins/alpine1: "true" name: "alpine1-prfs1-ghwvg" spec: containers: - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "alpine" imagePullPolicy: "IfNotPresent" name: "alpine" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - env: - name: "JENKINS_SECRET" ... image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes: - emptyDir: {} name: "workspace-volume" Running on alpine1-prfs1-ghwvg in /home/jenkins/workspace/CII_test_pod_template_nest [Pipeline] { [Pipeline] container [Pipeline] { [Pipeline] sh + whoami root [Pipeline] podTemplate [Pipeline] { [Pipeline] node Still waiting to schedule task 'golang-t6g4f-4tzqr' is offline Agent golang-t6g4f-4tzqr is provisioned from template Kubernetes Pod Template --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "https://callisto.dev.youview.co.uk/job/CII_test_pod_template_nest/13/" labels: jenkins: "slave" jenkins/golang: "true" name: "golang-t6g4f-4tzqr" spec: containers: - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "alpine" imagePullPolicy: "IfNotPresent" name: "alpine" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "golang" imagePullPolicy: "IfNotPresent" name: "golang" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - env: - name: "JENKINS_SECRET" ... image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes: - emptyDir: {} name: "workspace-volume" Running on golang-t6g4f-4tzqr in /home/jenkins/workspace/CII_test_pod_template_nest [Pipeline] { [Pipeline] container [Pipeline] { [Pipeline] sh + sleep 120 {code} |
New:
kubernetes plugin version: 1.17.2 When I run a podTemplate nested, it inherit the containers of the upper level podTemplate. It is a weird behaviour is better to explain it with an example Code: {code:java} podTemplate(showRawYaml: true, label: "alpine1", cloud: "Build farm", containers: [ containerTemplate(name: 'alpine', image: 'alpine', ttyEnabled: true, command: "cat")]) { node ("alpine1") { container('alpine') { sh 'whoami' podTemplate(showRawYaml: true, label: "golang", cloud: "Build farm", containers: [ containerTemplate(name: 'golang', image: 'golang', ttyEnabled: true, command: "cat")]) { node ("golang") { container('golang') { sh 'sleep 120' } } } } } } {code} Expected * alpine pod template containers: \{jnlp} \{alpine} * golang pod template containers: \{jnlp} \{golang} What I have: * alpine pod template containers: \{jnlp} \{alpine} * golang pod template containers: \{jnlp} \{golang} \{alpine} Log(removed env variables): {code:java} Still waiting to schedule task Waiting for next available executor on 'alpine1-dgpx2-5jp6k' Agent alpine1-prfs1-ghwvg is provisioned from template Kubernetes Pod Template --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "https://..." labels: jenkins: "slave" jenkins/alpine1: "true" name: "alpine1-prfs1-ghwvg" spec: containers: - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "alpine" imagePullPolicy: "IfNotPresent" name: "alpine" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - env: - name: "JENKINS_SECRET" ... image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes: - emptyDir: {} name: "workspace-volume" Running on alpine1-prfs1-ghwvg in /home/jenkins/workspace/CII_test_pod_template_nest [Pipeline] { [Pipeline] container [Pipeline] { [Pipeline] sh + whoami root [Pipeline] podTemplate [Pipeline] { [Pipeline] node Still waiting to schedule task 'golang-t6g4f-4tzqr' is offline Agent golang-t6g4f-4tzqr is provisioned from template Kubernetes Pod Template --- apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "https://..." labels: jenkins: "slave" jenkins/golang: "true" name: "golang-t6g4f-4tzqr" spec: containers: - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "alpine" imagePullPolicy: "IfNotPresent" name: "alpine" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - command: - "cat" env: - name: "JENKINS_SECRET" ... image: "golang" imagePullPolicy: "IfNotPresent" name: "golang" resources: limits: {} requests: {} securityContext: privileged: false tty: true volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false workingDir: "/home/jenkins" - env: - name: "JENKINS_SECRET" ... image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts: - mountPath: "/home/jenkins" name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes: - emptyDir: {} name: "workspace-volume" Running on golang-t6g4f-4tzqr in /home/jenkins/workspace/CII_test_pod_template_nest [Pipeline] { [Pipeline] container [Pipeline] { [Pipeline] sh + sleep 120 {code} |
Assignee | Original: Carlos Sanchez [ csanchez ] |