Skip to content

Commit

Permalink
Handle ExecStop in service unit
Browse files Browse the repository at this point in the history
When removing netdata and netdata-ui packages together (same yum
transaction), the netdata service is restarted by the ui package then
stopped immediately after by the removal the netdata package. This could
make the service to hang and leave it in a failed state and not entirely
removed. This patch adds a delay of 3 seconds before killing the main
netdata process. This gives enough time to netdata to start before being
stopped.

Signed-off-by: Thierry Escande <[email protected]>
  • Loading branch information
tescande committed Jan 20, 2025
1 parent 7d2d531 commit 3ad606a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions SOURCES/netdata-v2.1.0-handle-systemd-unit-stop.XCP-ng.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/system/systemd/netdata.service.v235.in b/system/systemd/netdata.service.v235.in
index 3d52677..055406d 100644
--- a/system/systemd/netdata.service.v235.in
+++ b/system/systemd/netdata.service.v235.in
@@ -13,6 +13,10 @@ EnvironmentFile=-/etc/default/netdata
ExecStart=@sbindir_POST@/netdata -D $EXTRA_OPTS
# XCP-ng: call script that will load /etc/sysconfig/iptables_netdata if it exists
ExecStartPre=/usr/libexec/netdata/xcpng-iptables-restore.sh
+# XCP-ng: Add a delay before stopping netdata to avoid the service to hang and
+# be in a failed state if stop is called too soon after a start.
+ExecStop=/usr/bin/sleep 3
+ExecStop=/usr/bin/kill --signal SIGTERM $MAINPID

# saving a big db on slow disks may need some time
TimeoutStopSec=150
3 changes: 3 additions & 0 deletions SPECS/netdata.spec
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Patch10: netdata-remove-fonts-2.0.0.patch
# XCP-ng specific patches
Patch1000: netdata-v2.1.0-fix-gcc4-static-struct-init.XCP-ng.patch
Patch1001: netdata-v2.1.0-firewall-management-in-systemd-unit.XCP-ng.patch
Patch1002: netdata-v2.1.0-handle-systemd-unit-stop.XCP-ng.patch

BuildRequires: zlib-devel
BuildRequires: git
Expand Down Expand Up @@ -293,6 +294,7 @@ if [ -d src/web/gui/v2 ] ; then
fi
%patch -P1000 -p1
%patch -P1001 -p1
%patch -P1002 -p1
cp %{SOURCE5} .

### BEGIN go.d.plugin
Expand Down Expand Up @@ -598,6 +600,7 @@ fi
- Create netdata-ui subpackage
- Add firewall rules management
- Enable xenstat plugin
- Handle service ExecStop to avoid service to hang when removing packages
- *** Upstream changelog ***
- * Sat Dec 21 2024 Didier Fabert <[email protected]> 2.1.0-3
- - go-module cannot be built in fc40
Expand Down

0 comments on commit 3ad606a

Please sign in to comment.