Skip to content

Commit 3840c56

Browse files
authored
fix(metrics): improve cleanup of old service
The core-update action was not correctly shutdown old node-exporter instances and node-monitor services.
2 parents 8cccdcf + 42c3e39 commit 3840c56

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

core/imageroot/etc/systemd/system/node_exporter.service

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Environment=PODMAN_SYSTEMD_UNIT=%n
77
EnvironmentFile=-/etc/nethserver/core.env
88
WorkingDirectory=/var/lib/nethserver/node/state
99
Restart=always
10+
RestartSec=3
11+
TimeoutStartSec=120
12+
# node_exporter exits with 143 on SIGTERM:
13+
SuccessExitStatus=143
1014
ExecStartPre=/bin/rm -f %t/%N.pid %t/%N.cid
1115
ExecStartPre=/usr/bin/mkdir -p /run/node_exporter
1216
ExecStart=/usr/bin/podman run \

core/imageroot/var/lib/nethserver/node/update-core.d/50start_node_exporter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ set -e
1111
if systemctl is-enabled --quiet node_exporter ; then
1212
systemctl restart node_exporter.service || :
1313
else
14+
# Make sure to stop all node_exporterX instances
15+
systemctl stop node_exporter*.service || :
1416
systemctl enable --now node_exporter.service
1517
fi

core/imageroot/var/lib/nethserver/node/update-core.d/80node_monitor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#
77

88
exec 1>&2
9-
set -e
109

1110
if systemctl -q is-active node-monitor.service; then
1211
echo "Disabling node-monitor as service"
12+
systemctl stop node-monitor
13+
# The disable may fail if the update-core has already removed the service file
1314
systemctl disable --now node-monitor
14-
rm -f /etc/systemd/system/node-monitor.service
15+
rm -fv /etc/systemd/system/node-monitor.service
1516
systemctl daemon-reload
1617
fi

0 commit comments

Comments
 (0)