[JIRA] (JENKINS-55611) Make EXECUTOR_NUMBER available for yaml definition

3 views
Skip to first unread message

bigdrum0@gmail.com (JIRA)

unread,
Jan 15, 2019, 11:17:02 PM1/15/19
to jenkinsc...@googlegroups.com
Drum Big created an issue
 
Jenkins / Improvement JENKINS-55611
Make EXECUTOR_NUMBER available for yaml definition
Issue Type: Improvement Improvement
Assignee: Carlos Sanchez
Components: kubernetes-plugin
Created: 2019-01-16 04:16
Priority: Minor Minor
Reporter: Drum Big

We have a use case that we would like to attach persistent volume to the pod during the build (to store cache data). To support concurrent build, we would like to assign volume claim based on the EXECUTOR_NUMBER, so that different concurrent build can use different volume.

Currently, this is impossible since EXECUTOR_NUMBER is not available in the agent definition.

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

jenkins-ci@carlossanchez.eu (JIRA)

unread,
Jan 16, 2019, 3:18:02 AM1/16/19
to jenkinsc...@googlegroups.com
Carlos Sanchez commented on Improvement JENKINS-55611
 
Re: Make EXECUTOR_NUMBER available for yaml definition

what are you calling EXECUTOR_NUMBER ? have you seen this somewhere?

why do you say "available for yaml definition" when the yaml already supports everything kubernetes does?

bigdrum0@gmail.com (JIRA)

unread,
Jan 16, 2019, 10:03:02 PM1/16/19
to jenkinsc...@googlegroups.com
Drum Big commented on Improvement JENKINS-55611

I'm talking about the environment variable "EXECUTOR_NUMBER" that jenkins defined (see https://wiki.jenkins.io/display/JENKINS/Building+a+software+project)

Basically, we would like to assign the pod with a PVC with name "workspace-cache-${env.JOB_NAME}-${env.EXECUTOR_NUMBER}", this name will be unique across all concurrent build. But it is still reusable for builds that are not overlapping in theirs durations.

Does that make sense?

jenkins-ci@carlossanchez.eu (JIRA)

unread,
Jan 17, 2019, 3:43:02 AM1/17/19
to jenkinsc...@googlegroups.com

I don't think this is possible, wdyt Andrew Bayer ?
Looks like EXECUTOR_NUMBER is only available inside node so not available when defining the pod template

def label = "maven-${UUID.randomUUID().toString()}"

podTemplate(label: label, yaml: """
spec:
  containers:
  - name: maven
    image: maven:alpine
    command:
    - cat
    tty: true
    env:
    - name: CONTAINER_ENV_VAR
      value: x${env.JOB_NAME}-${env.EXECUTOR_NUMBER}x
"""
  ) {

  echo "${env.JOB_NAME}-${env.EXECUTOR_NUMBER}"

  node(label) {
    stage('test') {
        container('maven') {
            echo "${env.JOB_NAME}-${env.EXECUTOR_NUMBER}"
            sh 'echo $CONTAINER_ENV_VAR'
        }
    }
  }
}
Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] echo
test/executor-number-null
[Pipeline] node
Still waiting to schedule task
‘Jenkins’ doesn’t have label ‘maven-aeef475c-5a8d-42e0-bbf2-a5b20b3a02e3’
Agent maven-aeef475c-5a8d-42e0-bbf2-a5b20b3a02e3-22x43-974rz is provisioned from template Kubernetes Pod Template
Agent specification [Kubernetes Pod Template] (maven-aeef475c-5a8d-42e0-bbf2-a5b20b3a02e3): 
yaml:

spec:
  containers:
  - name: maven
    image: maven:alpine
    command:
    - cat
    tty: true
    env:
    - name: CONTAINER_ENV_VAR
      value: xtest/executor-number-nullx


Running on maven-aeef475c-5a8d-42e0-bbf2-a5b20b3a02e3-22x43-974rz in /home/jenkins/workspace/test/executor-number
[Pipeline] {
[Pipeline] stage
[Pipeline] { (test)
[Pipeline] container
[Pipeline] {
[Pipeline] echo
test/executor-number-0
[Pipeline] sh
+ echo xtest/executor-number-nullx
xtest/executor-number-nullx
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
Finished: SUCCESS

andrew.bayer@gmail.com (JIRA)

unread,
Jan 17, 2019, 12:46:02 PM1/17/19
to jenkinsc...@googlegroups.com

Carlos Sanchez - correct, we don't have the executor number until we're on the executor, so...

bigdrum0@gmail.com (JIRA)

unread,
Jan 18, 2019, 10:27:03 AM1/18/19
to jenkinsc...@googlegroups.com
Drum Big commented on Improvement JENKINS-55611

hmm. Is it possible for the kubernetes plugin to allocate and provide some variable like this by itself? (Some kind of unique id that does not collide with other concurrent run, but is reused once the job is finished).

Rainer@Segebrecht.org (JIRA)

unread,
Mar 30, 2019, 4:47:03 PM3/30/19
to jenkinsc...@googlegroups.com

Hy Drum Big,

we have exactky the same challenge.

We're using the Jekins k8s Plugin, and have some big git repos. Therefore we cannot clone the repos in case of perfomance (it takes  4min).

So with a traditional Jenkins Infrastructure, there's a node, Jenkins sets up a unique directory for each EXECUTOR. As with kubernetes there's nothing like an executor for a node, while the so known nodes in kubernetes are only temporay spawned for one build.

As a result, there's no unique directory created by jenkins in the kubernetes world, therefore we need a possibility to map a persistent volume like the unique directory setup by jenkins. Otherwise we always have to clone the git repo (okay there's some performace boosts possible:  e.g: git clone -b <branch> <url> --depth=1, but that's not a great solution comparing to an update on a given repo).

Maybe there a possiblity to get the information of the unique jenkins path in order to use it as an ID for a unique persistence volume. 

jglick@cloudbees.com (JIRA)

unread,
Jun 4, 2019, 8:23:02 AM6/4/19
to jenkinsc...@googlegroups.com

Asking to bind EXECUTOR_NUMBER is proposing a solution (or really a workaround). To take a step back, the problem is the lack of a supported cache system. A persistent volume claim would presumably be required in this context, but it might be something that Jenkins manages for you; and depending on the volume type and build technology used, it may or may not offer concurrent access, cross-(K8s) node access, etc.

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:43:43 PM7/16/19
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Unassigned
 
Change By: Jesse Glick
Assignee: Carlos Sanchez
Reply all
Reply to author
Forward
0 new messages