diff mbox series

[ovs-dev] rhel: replace try-restart with restart in ovn-controller %postun

Message ID 20210922121740.59142-1-odivlad@gmail.com
State Accepted
Headers show
Series [ovs-dev] rhel: replace try-restart with restart in ovn-controller %postun | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Vladislav Odintsov Sept. 22, 2021, 12:17 p.m. UTC
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 <odivlad@gmail.com>
---
 rhel/ovn-fedora.spec.in | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Comments

Numan Siddique Sept. 24, 2021, 12:34 p.m. UTC | #1
On Wed, Sep 22, 2021 at 8:18 AM Vladislav Odintsov <odivlad@gmail.com> wrote:
>
> 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 <odivlad@gmail.com>

Thanks for the patch.

I applied this patch to the main branch and branch-21.09.  The patch
seems ok to me.

Thanks
Numan

> ---
>  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
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

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}