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

sh step within container step does not work when user is non-root

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • Jenkins 2.73.1, Kubernetes Plugin 1.0, Kubernetes 1.7.4

      Attempting to execute sh command within container step fails when the image user is not root.

      Replicate by running pipeline:

      podTemplate(name: 'my-pod', label: 'my-pod',
        containers: [
          containerTemplate(name: 'kubectl-cmd', 
                            image: 'wernight/kubectl:1.6.4',
                            ttyEnabled: true, 
                            command: 'cat', args:null)]) {
            node('my-pod') {
              stage('Test command') {
                container('kubectl-cmd') {
                  sh 'whoami'
                }
              }
            }
      } 

      `sh 'whoami'` does not successfully run, and the job fails with message: "ERROR: script returned exit code -2 "

      The image being run is here.

      I created a modified version of the image where simply "User kubectl" is removed. The job then runs as expected.

       

       

          [JENKINS-47389] sh step within container step does not work when user is non-root

          Chris Willmore created issue -
          Chris Willmore made changes -
          Attachment New: job-debug-logs.txt [ 40005 ]
          Lionel Orellana made changes -
          Comment [ I see the same thing running on Openshift 3.6, Jenkins 2.90, Kuberneter Plugin 1.1.

          The issue has something to do with JNLP4. 

          If I change the jnlp container image to jenkins/jnlp-slave:2.62-alpine and enable JNLP2 in Jenkins it works.  ]
          J Knurek made changes -
          Link New: This issue is related to JENKINS-46230 [ JENKINS-46230 ]
          J Knurek made changes -
          Link New: This issue is related to JENKINS-46055 [ JENKINS-46055 ]
          Jesse Glick made changes -
          Assignee Original: Carlos Sanchez [ csanchez ]
          Diego Rodriguez made changes -
          Assignee New: Carlos Sanchez [ csanchez ]
          Diego Rodriguez made changes -
          Assignee Original: Carlos Sanchez [ csanchez ]
          David Schott made changes -
          Link New: This issue is duplicated by JENKINS-47827 [ JENKINS-47827 ]
          David Schott made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]
          David Schott made changes -
          Link Original: This issue is duplicated by JENKINS-47827 [ JENKINS-47827 ]

            Unassigned Unassigned
            willmore Chris Willmore
            Votes:
            5 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: