[ovs-dev,v2,2/2] OpenvSwitch logrotate: Use ctl file path as target in ovs-appctl to reset logs

Message ID 20171108085907.20080-1-nusiddiq@redhat.com
State New
Headers show
Series
  • OVN DB log fixes
Related show

Commit Message

Numan Siddique Nov. 8, 2017, 8:59 a.m.
From: Numan Siddique <nusiddiq@redhat.com>

Presently, logrotate script, searches for the pid files in /var/log/openvswitch
and passes the pid file name (without .pid) as target to ovs-appctl. This approach
doesn't work for OVN DB servers since the ctl files are generated as "ovnnb_db.ctl"
and "ovnsb_db.ctl". So search for the .ctl files instead and use them as target to
ovs-appctl.

Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
---
 debian/openvswitch-switch.logrotate | 6 +++---
 rhel/etc_logrotate.d_openvswitch    | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Mark Michelson Nov. 9, 2017, 5:05 p.m. | #1
I feel much better about this approach.

On Wed, Nov 8, 2017 at 3:00 AM <nusiddiq@redhat.com> wrote:

> From: Numan Siddique <nusiddiq@redhat.com>
>
> Presently, logrotate script, searches for the pid files in
> /var/log/openvswitch
> and passes the pid file name (without .pid) as target to ovs-appctl. This
> approach
> doesn't work for OVN DB servers since the ctl files are generated as
> "ovnnb_db.ctl"
> and "ovnsb_db.ctl". So search for the .ctl files instead and use them as
> target to
> ovs-appctl.
>
> Suggested-by: Ben Pfaff <blp@ovn.org>
> Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
>
Acked-by: Mark Michelson <mmichels@redhat.com>

> ---
>  debian/openvswitch-switch.logrotate | 6 +++---
>  rhel/etc_logrotate.d_openvswitch    | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/debian/openvswitch-switch.logrotate
> b/debian/openvswitch-switch.logrotate
> index 7752af90c..802d36566 100644
> --- a/debian/openvswitch-switch.logrotate
> +++ b/debian/openvswitch-switch.logrotate
> @@ -8,9 +8,9 @@
>      postrotate
>         # Tell Open vSwitch daemons to reopen their log files
>         if [ -d /var/run/openvswitch ]; then
> -           for pidfile in `cd /var/run/openvswitch && echo *.pid`; do
> -               ovs-appctl -t "${pidfile%%.pid}" vlog/reopen 2>/dev/null
> || :
> -           done
> +            for ctl in /var/run/openvswitch/*.ctl; do
> +                ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || :
> +            done
>         fi
>      endscript
>  }
> diff --git a/rhel/etc_logrotate.d_openvswitch
> b/rhel/etc_logrotate.d_openvswitch
> index d93a56e51..ed7d733c9 100644
> --- a/rhel/etc_logrotate.d_openvswitch
> +++ b/rhel/etc_logrotate.d_openvswitch
> @@ -13,8 +13,8 @@
>      postrotate
>          # Tell Open vSwitch daemons to reopen their log files
>          if [ -d /var/run/openvswitch ]; then
> -            for pidfile in `cd /var/run/openvswitch && echo *.pid`; do
> -                ovs-appctl -t "${pidfile%%.pid}" vlog/reopen 2>/dev/null
> || :
> +            for ctl in /var/run/openvswitch/*.ctl; do
> +                ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || :
>              done
>          fi
>      endscript
> --
> 2.13.5
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>

Patch

diff --git a/debian/openvswitch-switch.logrotate b/debian/openvswitch-switch.logrotate
index 7752af90c..802d36566 100644
--- a/debian/openvswitch-switch.logrotate
+++ b/debian/openvswitch-switch.logrotate
@@ -8,9 +8,9 @@ 
     postrotate
 	# Tell Open vSwitch daemons to reopen their log files
 	if [ -d /var/run/openvswitch ]; then
-	    for pidfile in `cd /var/run/openvswitch && echo *.pid`; do
-		ovs-appctl -t "${pidfile%%.pid}" vlog/reopen 2>/dev/null || :
-	    done
+            for ctl in /var/run/openvswitch/*.ctl; do
+                ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || :
+            done
 	fi
     endscript
 }
diff --git a/rhel/etc_logrotate.d_openvswitch b/rhel/etc_logrotate.d_openvswitch
index d93a56e51..ed7d733c9 100644
--- a/rhel/etc_logrotate.d_openvswitch
+++ b/rhel/etc_logrotate.d_openvswitch
@@ -13,8 +13,8 @@ 
     postrotate
         # Tell Open vSwitch daemons to reopen their log files
         if [ -d /var/run/openvswitch ]; then
-            for pidfile in `cd /var/run/openvswitch && echo *.pid`; do
-                ovs-appctl -t "${pidfile%%.pid}" vlog/reopen 2>/dev/null || :
+            for ctl in /var/run/openvswitch/*.ctl; do
+                ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || :
             done
         fi
     endscript