Merge pull request #10751 from subhamkrai/fix-log-collector

core: fix logrotate bash check and periodicity logic
This commit is contained in:
Travis Nielsen authored and GitHub committed 2022-08-22 21:23:59 -06:00
commit e44eb7d0e7
1 file changed
+8 -6
+8 -6
View File
@@ -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{