Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defunct sh and sleep processes when running on slave-jnlp #714

Closed
DimeOne opened this issue Dec 7, 2017 · 6 comments
Closed

defunct sh and sleep processes when running on slave-jnlp #714

DimeOne opened this issue Dec 7, 2017 · 6 comments

Comments

@DimeOne
Copy link

DimeOne commented Dec 7, 2017

Hello,

When running multiple sh commands within a pipeline, I am receiving multiple defunct sh and sleep processes, if the job runs within a jenkins/jnlp-slave:latest docker container.

The master is running on the same host using jenkins/jenkins:lts-alpine and if the jobs runs on the master, I cannot find any defunct processes.

Setup

  • Master container using jenkins/jenkins:lts-alpine
  • Slave Agent container using jenkins/jnlp-slave:latest

Repro

The simplest pipeline to reproduce the problem may be:

node() {
  stage ('Run Tests') {
    sh 'echo "hello world"'
  }
    stage ('Run Tests2') {
    sh 'echo "hello world"'
  }
}

And after running the job list the defunct proccesses on the host:
$ ps aux | grep defunct | grep -v grep

10000     8054  0.0  0.0      0     0 ?        Z    16:34   0:00 [sh] <defunct>
10000     8057  0.0  0.0      0     0 ?        Z    16:34   0:00 [sleep] <defunct>
@oleg-nenashev
Copy link
Member

Likely it is a Pipeline issue, not the container one. Would you be able to try it on a similar environment without containers?

@carlossg
Copy link
Contributor

carlossg commented Dec 7, 2017

This could happen if the Java process dies abruptly without reaping children

@DimeOne
Copy link
Author

DimeOne commented Dec 7, 2017

I was not able to reproduce this using a jnlp connected agent running on a ubuntu vm.

The java process did not die in any instance. I guess that is why the master is being started with /bin/tini so that java does not use process id 1.

I will try to create an image where java is not running as PID1 and retry the test.

@DimeOne
Copy link
Author

DimeOne commented Dec 7, 2017

when running the jenkins/jnlp-slave:latest container interactively with bash and then running java does not result in defunct processes, so adding another process should solve it.

jenkinsci/docker#54

@DimeOne
Copy link
Author

DimeOne commented Dec 8, 2017

with tini as PID 1 I am not getting defunct processes, solved that in my image.

ENV TINI_VERSION v0.16.1
RUN wget -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini \
    && wget -O /tini.asc https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc \
    && gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
    && gpg --verify /tini.asc \
    && rm /tini.asc \
    && chmod 755 /tini

USER jenkins

ENTRYPOINT ["/tini", "--", "/docker-entrypoint.sh"]

@dduportal
Copy link
Contributor

Closing as the PR were refused (and the defunct process are not reproducible anymore)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants