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

Executing shell in a container with a custom workingDir times out

XMLWordPrintable

    • 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

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

              Created:
              Updated:
              Resolved: