From 9d4d5bc7025a026a7f11c52f48f1db0c00c4d5c9 Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Mon, 22 Aug 2022 11:30:36 +0530 Subject: [PATCH] core: fix logrotate bash check and periodicity logic we need use `!=` for string comparision in bash instead of `-ne`. Also, need to correct periodicity if condition to make it work as expected. Signed-off-by: subhamkrai --- pkg/operator/ceph/controller/spec.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/operator/ceph/controller/spec.go b/pkg/operator/ceph/controller/spec.go index b7fd70340..6cea7c79d 100644 --- a/pkg/operator/ceph/controller/spec.go +++ b/pkg/operator/ceph/controller/spec.go @@ -86,7 +86,7 @@ sed -i "s|*.log|$CEPH_CLIENT_ID.log|" "$LOG_ROTATE_CEPH_FILE" # replace default daily with given user input sed --in-place "s/daily/$PERIODICITY/g" "$LOG_ROTATE_CEPH_FILE" -if [ "$LOG_MAX_SIZE" -ne 0 ]; then +if [ "$LOG_MAX_SIZE" != "0" ]; then # adding maxsize $LOG_MAX_SIZE at the 4th line of the logrotate config file with 4 spaces to maintain indentation sed --in-place "4i \ \ \ \ maxsize $LOG_MAX_SIZE" "$LOG_ROTATE_CEPH_FILE" fi @@ -670,15 +670,17 @@ func LogCollectorContainer(daemonID, ns string, c cephv1.ClusterSpec) *v1.Contai maxLogSize = resource.MustParse(fmt.Sprintf("%dM", size)) } - periodicity := "daily" - if c.LogCollector.Periodicity == "1h" { + var periodicity string + if c.LogCollector.Periodicity == "1h" || c.LogCollector.Periodicity == "hourly" { periodicity = "hourly" - } else if strings.Contains(c.LogCollector.Periodicity, "h") || strings.Contains(c.LogCollector.Periodicity, "d") { - periodicity = "daily" - } else if c.LogCollector.Periodicity != "" { + } else if c.LogCollector.Periodicity == "weekly" || c.LogCollector.Periodicity == "monthly" { periodicity = c.LogCollector.Periodicity + } else { + periodicity = "daily" } + logger.Debugf("setting periodicity to %q. Supported periodicity are hourly, daily, weekly and monthly", periodicity) + return &v1.Container{ Name: logCollector, Command: []string{