Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58975

Executing shell in a container with a custom workingDir times out

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • Kubernetes 1.15, Jenkins 2.189, kubernetes-plugin 1.18.1
    • 1.22.1

      Hi,

      when using a custom working dir for a specific container, the workspace is mounted under this workingdir.

      Unfortunately, when running a shell script within this container, it runs by default using the workspace used for the POD (home/jenkins/agent/workspace)

      launching [nohup, sh, -c, (pid=$$$$; { while [ \( -d /proc/$$pid -o \! -d /proc/$$$$ \) -a -d '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2' -a \! -f '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/jenkins-result.txt' ]; do touch '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/jenkins-log.txt'; sleep 3; done } & jsc=durable-88384c7a8cc3f3d75dd32c12a311af37; JENKINS_SERVER_COOKIE=$$jsc 'sh' -xe '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/script.sh' > '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/jenkins-log.txt' 2>&1; echo $$? > '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/jenkins-result.txt.tmp'; mv '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/jenkins-result.txt.tmp' '/home/jenkins/agent/workspace/myjob_jenkins_agent@tmp/durable-f6c3edf2/jenkins-result.txt'; wait) >&- 2>&- &]
      

      The effect is that the shell script stalls the build and then times out.

      Use case to reproduce : https://github.com/hypnoce/kubernetes-plugin/commit/5382f88cfc7f8c1a65b4397b903d7f813cff5371

      There are several options to fix this.

      What do you think ?

      Thanks

          [JENKINS-58975] Executing shell in a container with a custom workingDir times out

          Narayanan Singaram added a comment - https://github.com/jenkinsci/kubernetes-plugin/pull/610 - PR for the fix.

          To make this work, you must change the working directory of all containers in the pod, including the jnlp container.

          I think that this JIRA is actually an improvement ? to make the container block aware of the container context (reflecting working dir and *workspace*) that allows to use different workingDir in the containers of kubernetes agent pods.

          Allan BURDAJEWICZ added a comment - To make this work, you must change the working directory of all containers in the pod, including the jnlp container. I think that this JIRA is actually an improvement ? to make the container block aware of the container context (reflecting working dir and * workspace *) that allows to use different workingDir in the containers of kubernetes agent pods.

          Ivan Kurnosov added a comment -

          The PR610 introduced another bug: https://issues.jenkins-ci.org/browse/JENKINS-60517

          Ivan Kurnosov added a comment - The PR610 introduced another bug: https://issues.jenkins-ci.org/browse/JENKINS-60517

          Francis JAC added a comment -

          Francis JAC added a comment - Is it considered solved by https://github.com/jenkinsci/kubernetes-plugin/pull/610  ?

            narayanan Narayanan Singaram
            hypnoce Francis JAC
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: