From 24273472e6eace6db33dece5499a03b80a168359 Mon Sep 17 00:00:00 2001 From: Chris Friesen Date: Fri, 5 Jun 2020 18:58:55 -0600 Subject: [PATCH] restart sysinv-fpga-agent when sysinv.conf changes There's a problem on initial startup where sysinv-fpga-agent starts up before sysinv.conf has the correct puppet server address, and then doesn't get restarted once sysinv.conf is updated. This creates a systemd entity that watches the sysinv.conf file and any time the file is modified it triggers a restart of sysinv-fpga-agent. There may be a cleaner way to do this, but I was unable to find one. Subscribing to the file in puppet didn't seem to work in my testing. Change-Id: I367eeaad5ee8cfeb3536281d78f44cea284f3de6 Story: 2006740 Task: 39927 --- .../sysinv-fpga-agent/centos/sysinv-fpga-agent.spec | 6 ++++++ sysinv/sysinv-fpga-agent/sysinv-conf-watcher.path | 5 +++++ sysinv/sysinv-fpga-agent/sysinv-conf-watcher.service | 11 +++++++++++ 3 files changed, 22 insertions(+) create mode 100644 sysinv/sysinv-fpga-agent/sysinv-conf-watcher.path create mode 100644 sysinv/sysinv-fpga-agent/sysinv-conf-watcher.service diff --git a/sysinv/sysinv-fpga-agent/centos/sysinv-fpga-agent.spec b/sysinv/sysinv-fpga-agent/centos/sysinv-fpga-agent.spec index 43cd488e76..048a816061 100644 --- a/sysinv/sysinv-fpga-agent/centos/sysinv-fpga-agent.spec +++ b/sysinv/sysinv-fpga-agent/centos/sysinv-fpga-agent.spec @@ -31,6 +31,8 @@ install -p -D -m 755 sysinv-fpga-agent %{buildroot}%{local_etc_initd}/sysinv-fpg install -d -m 755 %{buildroot}%{local_etc_pmond} install -p -D -m 644 sysinv-fpga-agent.conf %{buildroot}%{local_etc_pmond}/sysinv-fpga-agent.conf install -p -D -m 644 sysinv-fpga-agent.service %{buildroot}%{_unitdir}/sysinv-fpga-agent.service +install -p -D -m 644 sysinv-conf-watcher.service %{buildroot}%{_unitdir}/sysinv-conf-watcher.service +install -p -D -m 644 sysinv-conf-watcher.path %{buildroot}%{_unitdir}/sysinv-conf-watcher.path # Workaround to call "docker login" during startup. Called by puppet. install -d -m 755 %{buildroot}%{_exec_prefix}/local/sbin @@ -38,6 +40,8 @@ install -p -D -m 755 run_docker_login %{buildroot}%{_exec_prefix}/local/sbin/run %post /usr/bin/systemctl enable sysinv-fpga-agent.service >/dev/null 2>&1 +/usr/bin/systemctl enable sysinv-conf-watcher.service >/dev/null 2>&1 +/usr/bin/systemctl enable sysinv-conf-watcher.path >/dev/null 2>&1 %clean rm -rf $RPM_BUILD_ROOT @@ -48,4 +52,6 @@ rm -rf $RPM_BUILD_ROOT %{local_etc_initd}/sysinv-fpga-agent %{local_etc_pmond}/sysinv-fpga-agent.conf %{_unitdir}/sysinv-fpga-agent.service +%{_unitdir}/sysinv-conf-watcher.service +%{_unitdir}/sysinv-conf-watcher.path %{_exec_prefix}/local/sbin/run_docker_login diff --git a/sysinv/sysinv-fpga-agent/sysinv-conf-watcher.path b/sysinv/sysinv-fpga-agent/sysinv-conf-watcher.path new file mode 100644 index 0000000000..ca3fece52a --- /dev/null +++ b/sysinv/sysinv-fpga-agent/sysinv-conf-watcher.path @@ -0,0 +1,5 @@ +[Path] +PathChanged=/etc/sysinv/sysinv.conf + +[Install] +WantedBy=multi-user.target diff --git a/sysinv/sysinv-fpga-agent/sysinv-conf-watcher.service b/sysinv/sysinv-fpga-agent/sysinv-conf-watcher.service new file mode 100644 index 0000000000..30d3928a4a --- /dev/null +++ b/sysinv/sysinv-fpga-agent/sysinv-conf-watcher.service @@ -0,0 +1,11 @@ +[Unit] +Description=StarlingX conf watcher +After=sysinv-fpga-agent.service +Before=pmon.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/systemctl restart sysinv-fpga-agent.service + +[Install] +WantedBy=multi-user.target