From cca8bcb76764bc4fa5500320d6d159c19eca0070 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Wed, 3 Dec 2025 23:40:57 +0000 Subject: [PATCH] systemd: use subscribes to avoid daemon-reload race with service reload/restart --- cookbooks/hardware/recipes/default.rb | 16 ++++++++-------- cookbooks/systemd/resources/service.rb | 4 ++-- cookbooks/systemd/resources/timer.rb | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 04ead0b00..73fc91bf6 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -566,13 +566,6 @@ if watchdog_module action :install end - execute "systemctl-reload" do - action :nothing - command "systemctl daemon-reload" - user "root" - group "root" - end - directory "/etc/systemd/system.conf.d" do owner "root" group "root" @@ -584,7 +577,14 @@ if watchdog_module owner "root" group "root" mode "644" - notifies :run, "execute[systemctl-reload]" + end + + execute "systemctl-reload" do + action :nothing + command "systemctl daemon-reload" + user "root" + group "root" + subscribes :run, "template[/etc/systemd/system.conf.d/watchdog.conf]" end end diff --git a/cookbooks/systemd/resources/service.rb b/cookbooks/systemd/resources/service.rb index 8b380c306..34d4e6c50 100644 --- a/cookbooks/systemd/resources/service.rb +++ b/cookbooks/systemd/resources/service.rb @@ -193,7 +193,6 @@ action :create do group "root" mode "644" variables service_variables - notifies :run, "execute[systemctl-reload]" end execute "systemctl-reload" do @@ -201,6 +200,7 @@ action :create do command "systemctl daemon-reload" user "root" group "root" + subscribes :run, "template[#{config_name}]" end end @@ -212,7 +212,6 @@ action :delete do file config_name do action :delete - notifies :run, "execute[systemctl-reload]" end execute "systemctl-reload" do @@ -220,6 +219,7 @@ action :delete do command "systemctl daemon-reload" user "root" group "root" + subscribes :run, "file[#{config_name}]" end end diff --git a/cookbooks/systemd/resources/timer.rb b/cookbooks/systemd/resources/timer.rb index 2b21ba289..44dcaed1b 100644 --- a/cookbooks/systemd/resources/timer.rb +++ b/cookbooks/systemd/resources/timer.rb @@ -58,7 +58,6 @@ action :create do group "root" mode "644" variables timer_variables - notifies :run, "execute[systemctl-reload]" end execute "systemctl-reload" do @@ -66,6 +65,7 @@ action :create do command "systemctl daemon-reload" user "root" group "root" + subscribes :run, "template[#{config_name}]" end end @@ -79,7 +79,7 @@ action :delete do command "systemctl daemon-reload" user "root" group "root" - subscribes :run, "file[/etc/systemd/system/#{new_resource.timer}.timer]" + subscribes :run, "file[#{config_name}]" end end -- 2.39.5