Blob Blame History Raw
From 0bb71e1492b1ad442758399eb8dcb5f087d77f12 Mon Sep 17 00:00:00 2001
From: Nikhil Ladha <nladha@redhat.com>
Date: Wed, 28 Apr 2021 02:14:27 +0530
Subject: [PATCH 589/610] extras: fix for postscript failure on logrotation of
 snapd logs (#2310)

Issue:
On executing the logrotate command, the postscript runs as a separate process,
and when we do a grep for the snapd process it returns the PID of that
short-term process as well, and executing a kill on that throws the error.
To check a similar error could be seen if we replace the killall for bricks
log rotation with a for loop on PIDs.

Fix:
Use the killall command on the list of snapd processes instead of
using the kill command to individually kill them.

>Fixes: #2360
>Change-Id: I1ad6e3e4d74128706e71900d02e715635294ff72
>Signed-off-by: nik-redhat <nladha@redhat.com>

Upstream patch: https://github.com/gluster/glusterfs/pull/2310
BUG: 1668303

Change-Id: I59910fc3660e11e131b1aa813848c2e19cbffefd
Signed-off-by: nik-redhat <nladha@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/279533
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 extras/glusterfs-logrotate | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/extras/glusterfs-logrotate b/extras/glusterfs-logrotate
index 75f700e..2b9028b 100644
--- a/extras/glusterfs-logrotate
+++ b/extras/glusterfs-logrotate
@@ -45,3 +45,22 @@
   compress
   delaycompress
 }
+
+# Rotate snapd log
+/var/log/glusterfs/snaps/*/*.log {
+    sharedscripts
+    weekly
+    maxsize 10M
+    minsize 100k
+
+    # 6 months of logs are good enough
+    rotate 26
+
+    missingok
+    compress
+    delaycompress
+    notifempty
+    postrotate
+    /usr/bin/killall -HUP `pgrep -f "glusterfs.*snapd"` > /dev/null 2>&1 || true
+    endscript
+}
-- 
1.8.3.1