In commit [1] support for graceful stop during ovn-controller RPM
upgrade was added. Unfortunately there was an error, where after
ovn-controller service stop via ctl socket was invoked, systemd
service transitioned to dead state and subsequent try-restart
didn't start the service.

This commit fixes such situation by checking actual ovn-controller
service status and doing an unconditional restart if service was
running before upgrade.

[1] 
https://github.com/ovn-org/ovn/commit/8540c544f0e67d3dc475bbeb350ea3053a1772dd

Signed-off-by: Vladislav Odintsov <odiv...@gmail.com>
---
 rhel/ovn-fedora.spec.in | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/rhel/ovn-fedora.spec.in b/rhel/ovn-fedora.spec.in
index 5fe0f990f..2d6399c53 100644
--- a/rhel/ovn-fedora.spec.in
+++ b/rhel/ovn-fedora.spec.in
@@ -401,22 +401,19 @@ fi
 
 %postun host
 if [ "$1" -ge "1" ] ; then
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
     # Package upgrade, not uninstall
     # We perform lightweight stop here not to affect active traffic during
     # ovn-controller upgrade.
     # Ideally this would be held by systemd, but it's impossible
     # to pass custom restart command to systemd service.
-    %{_datadir}/ovn/scripts/ovn-ctl stop_controller --restart
-fi
-%if 0%{?systemd_postun_with_restart:1}
-    %systemd_postun_with_restart ovn-controller.service
-%else
-    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
-    if [ "$1" -ge "1" ] ; then
-        # Package upgrade, not uninstall
-        /bin/systemctl try-restart ovn-controller.service >/dev/null 2>&1 || :
+    systemctl -q is-active ovn-controller
+    if [ "$?" -eq 0 ] ; then
+        # ovn-controller was running prior to upgrade, so do a graceful restart
+        %{_datadir}/ovn/scripts/ovn-ctl stop_controller --restart >/dev/null 
2>&1 || :
+        /bin/systemctl restart ovn-controller.service >/dev/null 2>&1 || :
     fi
-%endif
+fi
 
 %postun vtep
 %if 0%{?systemd_postun_with_restart:1}
-- 
2.30.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to