[JIRA] (JENKINS-62160) persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines

8 views
Skip to first unread message

david.warburton@gmail.com (JIRA)

unread,
May 4, 2020, 5:11:02 PM5/4/20
to jenkinsc...@googlegroups.com
david warburton created an issue
 
Jenkins / Bug JENKINS-62160
persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2020-05-04 21:10
Priority: Minor Minor
Reporter: david warburton

I have this feature working in a scripted pipeline but when I tried to use it in a declarative pipeline it would never create the workspace volume as a persistent volume claim, it would only mount "emptyDir" volumes for the workspace. 

The declarative pipeline I'm using is

pipeline {
 agent {
   kubernetes {
     yamlFile 'jenkins/pv-pod.yaml'
     defaultContainer 'tree'
   }
 }
 options {
   podTemplate(workspaceVolume: persistentVolumeClaimWorkspaceVolume(claimName: 'workspace', readOnly: false))
 }
 stages {
   stage('read workspace') {
     steps {
       echo 'current env'
       sh 'env'
       sh '/usr/bin/tree'
       echo 'previous env'
       sh 'cat old-env.txt || true'
       sh 'env > old-env.txt'
     }
   }
 }
}

 

With a 'pv-pod.yaml' file with these contents

apiVersion: v1
kind: Pod
spec:
 containers:
 - name: tree
   image: iankoulski/tree
   command:
   - /bin/cat
     tty: true

This is in kubenernetes-plugin version 1.25.3.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

david.warburton@gmail.com (JIRA)

unread,
May 4, 2020, 5:12:03 PM5/4/20
to jenkinsc...@googlegroups.com

david.warburton@gmail.com (JIRA)

unread,
May 4, 2020, 6:22:05 PM5/4/20
to jenkinsc...@googlegroups.com

This is the generated yaml (anonimized)

Agent anwhy-fklcld-fuckqof-0nfqavjvebjog-udedqcviwl-vwbxnctaf-8-f664h is provisioned from template vcres-tjkgar_msiukwa_0Dxnpfmycoprj-firsqsxnhi-fwbmghhdm_2-k4ksh-7njl0
---
apiVersion: "v1"
kind: "Pod"
metadata:
  annotations:
    buildUrl: "https://tv.fmoyos-pixchwrnpnvx.ush/wxoyciu/eld/PslgdnEmvukdyakmgi/tqv/ver-cjxujky-cnybig/ktm/dlobiak%675Bejoolkhhobs-kbefsuasgk-clmbrcmxy/6/"
    runUrl: "job/HbypjmSytbncdpinxr/qko/vxv-pqtkmeu-eydfbq/sgw/sfmddvo%762Vvmqjvkxrqny-brfxhedxdu-ythsihpma/8/"
  labels:
    jenkins: "slave"
    jenkins/label: "agawg-nacfrw_dkwnknh_4Qpwsnvjwaeuf-auyqsweurs-xiegsouti_5-x4cwt"
  name: "mpaid-qguadg-nqxbyop-4cqwjivsgtfxq-twmrcsovdn-vhbojcfom-4-f581d"
spec:
  containers:
  - command:
    - "/bin/cat"
    image: "iankoulski/tree"
    name: "tree"
    tty: true
    volumeMounts:
    - mountPath: "/home/jenkins/agent"
      name: "workspace-volume"
      readOnly: false
  - env:
    - name: "JENKINS_SECRET"
      value: "********"
    - name: "JENKINS_TUNNEL"
      value: "02.147.7.56:1864"
    - name: "JENKINS_AGENT_NAME"
      value: "tgrmu-bgqrng-kkyqlcy-8hnyafxtetumr-shfdkhyxbo-cnjpbanyw-4-p847s"
    - name: "JENKINS_NAME"
      value: "utgyv-jbsnfr-blwxojh-4hthpvnmkqatm-iipmqvfxtx-ogetrxvlx-4-p847s"
    - name: "JENKINS_AGENT_WORKDIR"
      value: "/home/jenkins/agent"
    - name: "JENKINS_URL"
      value: "https://xy.kecynt-ytjugchsvagx.com/jenkins/"
    image: "jenkins/jnlp-slave:4.0.1-1"
    name: "jnlp"
    resources:
      requests:
        cpu: "100m"
        memory: "256Mi"
    volumeMounts:
    - mountPath: "/home/jenkins/agent"
      name: "workspace-volume"
      readOnly: false
  nodeSelector:
    beta.kubernetes.io/os: "linux"
  restartPolicy: "Never"
  securityContext: {}
  volumes:
  - emptyDir:
      medium: ""
    name: "workspace-volume"

david.warburton@gmail.com (JIRA)

unread,
May 5, 2020, 10:35:02 AM5/5/20
to jenkinsc...@googlegroups.com
david warburton updated an issue
 
Change By: david warburton
I have this feature working in a scripted pipeline but when I tried to use it in a declarative pipeline it would never create the workspace volume as a persistent volume claim, it would only mount "emptyDir" volumes for the workspace. 

The declarative pipeline I'm using is
{code:java}

pipeline {
 agent {
   kubernetes {
     yamlFile 'jenkins/pv-pod.yaml'
     defaultContainer 'tree'
   }
 }
 options {
   podTemplate(workspaceVolume: persistentVolumeClaimWorkspaceVolume(claimName: 'workspace', readOnly: false))
 }
 stages {
   stage('read workspace') {
     steps {
       echo 'current env'
       sh 'env'
       sh '/usr/bin/tree'
       echo 'previous env'
       sh 'cat old-env.txt || true'
       sh 'env > old-env.txt'
     }
   }
 }
}
{code}

 

With a 'pv-pod.yaml' file with these contents
{code:java}

apiVersion: v1
kind: Pod
spec:
 containers:
 - name: tree
   image: iankoulski/tree
   command:
   - /bin/cat
     tty: true
{code}

This is in kubenernetes-plugin version 1.25.3.

 
Reply all
Reply to author
Forward
0 new messages