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

cardano-node expects SIGINT not SIGTERM for graceful shutdown #2627

Closed
nyetwurk opened this issue Apr 19, 2021 · 15 comments
Closed

cardano-node expects SIGINT not SIGTERM for graceful shutdown #2627

nyetwurk opened this issue Apr 19, 2021 · 15 comments

Comments

@nyetwurk
Copy link

docker stop does not politely shut down the cardano-node container built by:

https://github.com/input-output-hk/cardano-node/blob/9088aacfae5c46a8b4bd4ed056f8e37d7cf42811/nix/docker.nix#L100

This is because cardano-node expects SIGINT, not SIGTERM (the docker default).

In a Dockerfile, this can be overridden by STOPSIGNAL, but nix-docker doesn't seem to be aware that is an option.

docker kill -s INT isn't useful, since it doesn't fall back on KILL if it fails, and it also exits immediately, which means you need to do a docker wait... which is useless because docker, in their infinite wisdom, don't have a timeout option for wait.

Then again, you'd think they'd add a --signal option for docker stop and docker restart.

@nyetwurk
Copy link
Author

nyetwurk commented Apr 19, 2021

It's possible something like

config = {
      EntryPoint = [ "${entry-point}/bin/entry-point" ];
      StopSignal = "INT";
    };

may work

@nyetwurk
Copy link
Author

nyetwurk commented Apr 19, 2021

It would be nice if EntryPoint was a bit more deterministic to make it easier to wrap.

Even better ${entry-point} could have a symlink in /usr/lib/ pointing to it or something.

This makes it almost impossible to use the upstream docker image as a base for another:

$ docker inspect cardano | jq '.[].Config.Entrypoint[0]' -r
/nix/store/bdyld123qfg3x5vqqh4dkbvfxvfrzd3h-entry-point/bin/entry-point

@nyetwurk
Copy link
Author

Something like this worked for me to create something hookable:

ARG version=1.26.2
FROM inputoutput/cardano-node:${version}

RUN mkdir -p /usr/local/bin
RUN ln -s $(ls -1 /nix/store/*-entry-point/bin/* /nix/store/*-cardano-node-*/bin/*) /usr/local/bin/

@tdiesler
Copy link
Contributor

This is a duplicate of #2353 which would be fixed by PR #2608.

In the meantime, you can use the nessusio/cardano-node image which is a multiarch clone of the IOHK image that among other things also fixes this issue.

@nyetwurk
Copy link
Author

nyetwurk commented Apr 22, 2021

Curious why cardano-node doesn't just natively trap SIGTERM? There seems to be an excessive amount of bash support junk that could just be added directly to cardano-node, including all of the environment handling and command line varietals.

@tdiesler
Copy link
Contributor

tdiesler commented Apr 22, 2021

This might be a question best answered by cardano-node itself.

As it stands now, substantial improvements to the cardano-node image are available and have been for months. From my part the proposal can be adopted, partially adopted, rejected for a better proposal, etc. It is also not a conclusive proposal that claims to set things in stone. Instead it proposes a number of small iterative steps to the cardano-node image, which over time can be modified and expanded on by folks who like to contribute to the cardano project with their domain knowledge.

Perhaps they are not adopting because of legal issues (i.e. a suitable contributor agreement), who knows?
Anyway, the ball is with IOHK.

@juampe
Copy link

juampe commented Apr 25, 2021

I solved this issue with "STOPSIGNAL SIGINT" statement in Dockerfile
https://github.com/juampe/cardano-docker

@tdiesler
Copy link
Contributor

@juampe Yes, we are likely going to do this as well in the Nix build

  • #49 Simplify stop signal handling by using SIGINT directly

@nyetwurk
Copy link
Author

nyetwurk commented Jul 9, 2021

952ce08

@tdiesler
Copy link
Contributor

This should be out of date

@nyetwurk
Copy link
Author

In which version is it released? I have a workaround for it in our CI and need to know on which versions it is no longer needed.

@nyetwurk
Copy link
Author

I solved this issue with "STOPSIGNAL SIGINT" statement in Dockerfile
https://github.com/juampe/cardano-docker

This is the same workaround I am using.

@tdiesler
Copy link
Contributor

It'll be in 1.28.0

@jterrier84
Copy link

Is the solution with "STOPSIGNAL SIGINT" in the dockerfile still valid for version 1.34.1? I used it but my container is not stopping gracefully. My dockerfile is this one: https://github.com/jterrier84/Cardano-node-docker/blob/master/dockerfiles/armada-cn-arm64.dockerfile. Would appreciate your help.

@Jimbo4350
Copy link
Contributor

Closing this. If this is still relevant please reopen.

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

No branches or pull requests

5 participants