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
This commit is contained in:
Chris Friesen 2020-06-05 18:58:55 -06:00
parent 6d639fca5d
commit 24273472e6
3 changed files with 22 additions and 0 deletions

View File

@ -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 -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.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-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. # Workaround to call "docker login" during startup. Called by puppet.
install -d -m 755 %{buildroot}%{_exec_prefix}/local/sbin 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 %post
/usr/bin/systemctl enable sysinv-fpga-agent.service >/dev/null 2>&1 /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 %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -48,4 +52,6 @@ rm -rf $RPM_BUILD_ROOT
%{local_etc_initd}/sysinv-fpga-agent %{local_etc_initd}/sysinv-fpga-agent
%{local_etc_pmond}/sysinv-fpga-agent.conf %{local_etc_pmond}/sysinv-fpga-agent.conf
%{_unitdir}/sysinv-fpga-agent.service %{_unitdir}/sysinv-fpga-agent.service
%{_unitdir}/sysinv-conf-watcher.service
%{_unitdir}/sysinv-conf-watcher.path
%{_exec_prefix}/local/sbin/run_docker_login %{_exec_prefix}/local/sbin/run_docker_login

View File

@ -0,0 +1,5 @@
[Path]
PathChanged=/etc/sysinv/sysinv.conf
[Install]
WantedBy=multi-user.target

View File

@ -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