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

Node exporter always return 143 when receiving a SIGTERM #2356

Open
rkachach opened this issue Apr 25, 2022 · 11 comments
Open

Node exporter always return 143 when receiving a SIGTERM #2356

rkachach opened this issue Apr 25, 2022 · 11 comments
Labels

Comments

@rkachach
Copy link

rkachach commented Apr 25, 2022

Host operating system: output of uname -a

Linux fedora 5.15.14-200.fc35.x86_64 #1 SMP Tue Jan 11 16:49:27 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

node_exporter version: output of node_exporter --version

latest version (as run by Docker)
quay.io/prometheus/node-exporter:latest

node_exporter command line flags

docker run -d --net="host" --pid="host" -v "/:/host:ro,rslave" 'quay.io/prometheus/node-exporter:latest' --path.rootfs=/host

Are you running node_exporter in Docker?

What did you do that produced an error?

docker stop <container_id>

What did you expect to see?

exit value code 0

What did you see instead?

Exit value code is always 143. It seems like node-exporter is not handling correctly the SIGTERM signal (sent when docker stop). The code value (143) is generated normally when a SIGTERM is sent by the underlying operating system. Hence we are stopping the container properly (using docker stop) the code value should be zero. Same happens when podman is used instead of docker.

@ventifus
Copy link
Contributor

ventifus commented Jun 8, 2022

As far as I can tell it is quite common for programs to exit with 143. Even sleep will exit with 143 when TERM'd. Do you have an example of something that exits with 0 in this situation? Can you elaborate on what problem this is causing?

@rkachach
Copy link
Author

@ventifus thanks for taking time to look into this. Basically, the node-exporter is the only process that when stopping its container exists with 143 instead of zero. All the other prometheus daemons when stopped (by using docker stop) finish and return a 0 code. In our env, since we are running the container in systemd, the service ends up in error state even when stopped gracefully.

@discordianfish
Copy link
Member

Hrm I'm not 100% what the right approach is but if all other prometheus components behave like that, we should probably too. @SuperQ wdyt?

@rkachach
Copy link
Author

rkachach commented Sep 2, 2022

Any update on this? thanks.

@SuperQ
Copy link
Member

SuperQ commented Sep 2, 2022

I wonder if this is something we should add to the exporter-toolkit.

@rkachach
Copy link
Author

rkachach commented Jul 3, 2023

any update on this?

@discordianfish
Copy link
Member

@rkachach No, feel free to implement this.

@rkachach
Copy link
Author

rkachach commented Jul 3, 2023

@rkachach No, feel free to implement this.

I'll be more than happy to contribute but I'm not familiar with the node-exporter code base nor what would be the best solution, so in practice I can't fix it at this moment (otherwise I would have already done it).

@Bogay
Copy link

Bogay commented Jul 7, 2023

I am not very sure of the best way to handle this, but perhaps adding a signal handling to call server.Shutdown is enough?
FYI: https://gin-gonic.com/docs/examples/graceful-restart-or-stop/

@discordianfish
Copy link
Member

Its easy: Trap the signal, exit with 0 in the handler. But as @SuperQ said, adding this to the exporter-toolkit would be best

@Bogay
Copy link

Bogay commented Jul 10, 2023

@discordianfish Do you mean calling os.Exit(0) in the signal handler?

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

No branches or pull requests

5 participants