c460ee
From 0bb71e1492b1ad442758399eb8dcb5f087d77f12 Mon Sep 17 00:00:00 2001
c460ee
From: Nikhil Ladha <nladha@redhat.com>
c460ee
Date: Wed, 28 Apr 2021 02:14:27 +0530
c460ee
Subject: [PATCH 589/610] extras: fix for postscript failure on logrotation of
c460ee
 snapd logs (#2310)
c460ee
c460ee
Issue:
c460ee
On executing the logrotate command, the postscript runs as a separate process,
c460ee
and when we do a grep for the snapd process it returns the PID of that
c460ee
short-term process as well, and executing a kill on that throws the error.
c460ee
To check a similar error could be seen if we replace the killall for bricks
c460ee
log rotation with a for loop on PIDs.
c460ee
c460ee
Fix:
c460ee
Use the killall command on the list of snapd processes instead of
c460ee
using the kill command to individually kill them.
c460ee
c460ee
>Fixes: #2360
c460ee
>Change-Id: I1ad6e3e4d74128706e71900d02e715635294ff72
c460ee
>Signed-off-by: nik-redhat <nladha@redhat.com>
c460ee
c460ee
Upstream patch: https://github.com/gluster/glusterfs/pull/2310
c460ee
BUG: 1668303
c460ee
c460ee
Change-Id: I59910fc3660e11e131b1aa813848c2e19cbffefd
c460ee
Signed-off-by: nik-redhat <nladha@redhat.com>
c460ee
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/279533
c460ee
Tested-by: RHGS Build Bot <nigelb@redhat.com>
c460ee
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
c460ee
---
c460ee
 extras/glusterfs-logrotate | 19 +++++++++++++++++++
c460ee
 1 file changed, 19 insertions(+)
c460ee
c460ee
diff --git a/extras/glusterfs-logrotate b/extras/glusterfs-logrotate
c460ee
index 75f700e..2b9028b 100644
c460ee
--- a/extras/glusterfs-logrotate
c460ee
+++ b/extras/glusterfs-logrotate
c460ee
@@ -45,3 +45,22 @@
c460ee
   compress
c460ee
   delaycompress
c460ee
 }
c460ee
+
c460ee
+# Rotate snapd log
c460ee
+/var/log/glusterfs/snaps/*/*.log {
c460ee
+    sharedscripts
c460ee
+    weekly
c460ee
+    maxsize 10M
c460ee
+    minsize 100k
c460ee
+
c460ee
+    # 6 months of logs are good enough
c460ee
+    rotate 26
c460ee
+
c460ee
+    missingok
c460ee
+    compress
c460ee
+    delaycompress
c460ee
+    notifempty
c460ee
+    postrotate
c460ee
+    /usr/bin/killall -HUP `pgrep -f "glusterfs.*snapd"` > /dev/null 2>&1 || true
c460ee
+    endscript
c460ee
+}
c460ee
-- 
c460ee
1.8.3.1
c460ee