[JIRA] (JENKINS-58709) Nested pod templates inherit container of upper level pod

4 views
Skip to first unread message

sergio.merino.a@gmail.com (JIRA)

unread,
Jul 29, 2019, 10:12:04 AM7/29/19
to jenkinsc...@googlegroups.com
Sergio Merino created an issue
 
Jenkins / Bug JENKINS-58709
Nested pod templates inherit container of upper level pod
Issue Type: Bug Bug
Assignee: Carlos Sanchez
Components: kubernetes-plugin
Created: 2019-07-29 14:11
Priority: Minor Minor
Reporter: Sergio Merino

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://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

 

 

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

sergio.merino.a@gmail.com (JIRA)

unread,
Jul 29, 2019, 1:30:02 PM7/29/19
to jenkinsc...@googlegroups.com
Sergio Merino updated an issue
Change By: Sergio Merino
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}
callisto . dev . youview . co.uk/job/CII_test_pod_template_nest/13/ "
callisto . dev . youview . co.uk/job/CII_test_pod_template_nest/13/ "
{code}
 

 

 

 
Reply all
Reply to author
Forward
0 new messages