Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Running in a jenkins slave kubernetes pod fails #35

Closed
tculp opened this issue Jun 10, 2020 · 6 comments
Closed

Running in a jenkins slave kubernetes pod fails #35

tculp opened this issue Jun 10, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@tculp
Copy link

tculp commented Jun 10, 2020

Using this image in a jenkins slave pod fails.

Here is an example jenkinsfile (using the Kuberneted plugin):

podTemplate(
  containers: [
    containerTemplate(
      image: "curlimages/curl:7.70.0",
      name: 'curl',
      command: 'cat',
      ttyEnabled: true
    )
  ]
)
{
node(POD_LABEL){

  stage('Curl google'){
    container('curl') {
      sh "curl google.com"
    }
  }
}
}

Which fails with:

[Pipeline] stage
[Pipeline] { (Curl google)
[Pipeline] container
[Pipeline] {
[Pipeline] sh
process apparently never started in /home/jenkins/agent/workspace/network-debugger_master@tmp/durable-6e3552c0
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }

Meanwhile, the following Jenkinsfile works as expected:

podTemplate(
  containers: [
    containerTemplate(
      image: "centos:8",
      name: 'curl',
      command: 'cat',
      ttyEnabled: true
    )
  ]
)
{
node(POD_LABEL){

  stage('Curl google'){
    container('curl') {
      sh "curl google.com"
    }
  }
}
}
@xquery xquery added the bug Something isn't working label Jun 11, 2020
@xquery
Copy link
Member

xquery commented Jun 11, 2020

we would need more logs to debug what is going on here eg. from what you have shown it looks like curl is never even invoked.

a random guess - you might try invoking the curlimages/curl entry script.

@xquery
Copy link
Member

xquery commented Aug 19, 2020

without any additional info (and not knowing the specifics of your jenkins & kubernetes environment) it is hard to see how we can help - I am going to close this issue but will try a few random guesses (feel free to comment and I will reopen if you think it would help).

running

> docker run --rm -it curlimages/curl which curl

shows curl exists at /usr/bin/curl so should be on the $PATH

Note that curl in the docker container runs under the curl_user (thats an explicit design decision) ... it is unclear in jenkins/kubernetes if a user is being specified.

Maybe the centos version has a ./curlrc file amending curl behaviour eg. with that particular uri you would need to supply -L to ensure redirects are being followed eg.

> docker run --rm -it curlimages/curl curl -L google.com

@xquery xquery closed this as completed Aug 19, 2020
@cmamigonian
Copy link

I am seeing this too, and maybe I can explain a little more. The pod uses the curl image and runs cat as a noop just to start the container, then within the Jenkins stage step--which is running inside the curl container in the pod--we run the curl command in a shell. It appears as if running cat in the container is just hanging the shell so we never actually get to executing the curl command. I also notice this if I pull the image locally and run cat: it just hangs.

@tculp
Copy link
Author

tculp commented Feb 14, 2021

I do see that it hangs forever locally with a cat call. However, using any other image that I've encountered, such as ubuntu or alpine, does the same, and successfully works in a Jenkins + Kube setup. I'm not sure what the difference is with this image.

@wayne0811
Copy link

Ran into this issue as well. Eventually I found that this is documented in the Kubernetes plugin: https://github.com/jenkinsci/kubernetes-plugin#pipeline-sh-step-hangs-when-multiple-containers-are-used

Any of the following fixes worked for me:

  • Add runAsUser: '1000' to the podTemplate
  • Add runAsUser: '1000' to the curl containerTemplate
  • Add runAsUser: '0' to the curl containerTemplate

@alpeshjikadra
Copy link

I was facing the same issue from today morning,

As a solution I have recreated docker image which was getting used in container with USER 1000 option. and it started working

i.e. Dockerfile

`FROM curlimages/curl:7.78.0

USER 1000`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

5 participants