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

Do we need a init system? #2

Closed
gtcno opened this issue Oct 10, 2017 · 9 comments
Closed

Do we need a init system? #2

gtcno opened this issue Oct 10, 2017 · 9 comments

Comments

@gtcno
Copy link
Contributor

gtcno commented Oct 10, 2017

See https://github.com/Yelp/dumb-init

@gtcno gtcno added the question label Oct 10, 2017
@joakibj
Copy link
Contributor

joakibj commented Oct 10, 2017

Maybe, probably. Otherwise we likely need some different way of starting apps.

In this current baseimage draft and our current app we use CMD or ENTRYPOINT to start our apps with sh.

According to this: https://pracucci.com/graceful-shutdown-of-kubernetes-pods.html the alpine linux shell, /bin/ash does not propagate signals to its children. So the java app does not see the SIGTERM and thus frameworks like spring boot and camel do not gracefully shut down.

We need to verify this behaviour and find a solution, where dumb-init could be one.

@davidsteinsland

@davidsteinsland
Copy link
Member

We use the exec form to start Java apps, which means they get pid 1. So there shouldn't be any issues regarding signals, but I'll test anyway.

@ghost
Copy link

ghost commented Apr 6, 2018

We are having problems taking heap dumps.

Might be related to this:
docker-library/openjdk#76.

@ghost ghost reopened this Apr 6, 2018
@ghost
Copy link

ghost commented Apr 6, 2018

Verified that heap dump is possible when running the java process with PID > 1.
Fails with PID 1. Docker > 1.13 has the --init flag which can be set on the the docker hosts
which will run the container with https://github.com/krallin/tini.

However we still need to include jmap, jstack etc to this baseimage, I think.

@joakibj
Copy link
Contributor

joakibj commented Apr 6, 2018

Yeah we need this then. Maybe we should set HeapDumpOnOutOfMemoryError and HeapDumpPath as default flags as well. That way NAIS can automate retrieval of these?

Regarding the jmap, jstack etc utils, they are part of the JDK and not the JRE. So we either need to base the baseimages of the JDK (increasing layer size) or include them through some other mechanism.

@joakibj
Copy link
Contributor

joakibj commented Apr 18, 2018

@gtcno are you planning to add the --init flag when starting docker containers in NAIS? I made a branch adding dumb-init to java-8, however I guess this is not needed if you guys add the tinit functionality.

Then we only need to add the openjdk:8-jdk-alpine to java-8. The difference in layer is 22MB which is not huge. However, being able to make heapdumps is useful. @davidsteinsland thoughts?

@davidsteinsland
Copy link
Member

I must admit, I have completely forgotten about this issue.

If we're not using the --init feature, we could have a bash entrypoint which uses trap to receive SIGTERM, which it could forward to java (if it's required to have java running on pid > 1).

Changing the base image to java-8 sounds good to me, a few extra megabytes doesn't kill anyone. 👍

@gtcno
Copy link
Contributor Author

gtcno commented Apr 19, 2018

First cut adding the flag to the daemon failed. Daemonsets pods failed. I did not try out why. I'll look into it. However, can't see why we should not add it to the baseimage. It will work fine with the flag det globally as well

@joakibj
Copy link
Contributor

joakibj commented Apr 20, 2018

It wasn't possible to add the --init flag globally in NAIS, so we add the dumb-init to our baseimages for now.

@joakibj joakibj self-assigned this Apr 20, 2018
joakibj added a commit that referenced this issue Apr 22, 2018
dump utils.
Added dumb-init as entrypoint for run-java.sh. Fixes #2 for java-9.
@joakibj joakibj mentioned this issue Apr 22, 2018
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

3 participants