From e54d9b698a78d5780eab2aa94b957f331b695f1a Mon Sep 17 00:00:00 2001 From: Gil Bregman Date: Tue, 5 Mar 2024 14:52:52 +0200 Subject: [PATCH] Increase the number of log file backup directories and add the limit to the conf file Fixes #477 Signed-off-by: Gil Bregman --- ceph-nvmeof.conf | 1 + control/utils.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ceph-nvmeof.conf b/ceph-nvmeof.conf index 4c58c7ae..c3cefc4d 100644 --- a/ceph-nvmeof.conf +++ b/ceph-nvmeof.conf @@ -27,6 +27,7 @@ bdevs_per_cluster = 32 #verbose_log_messages = True #max_log_file_size_in_mb=10 #max_log_files_count=20 +#max_log_directory_backups=10 # # Notice that if you change the log directory the log files will only be visible inside the container # diff --git a/control/utils.py b/control/utils.py index 8cafb3ba..1a4da5c4 100644 --- a/control/utils.py +++ b/control/utils.py @@ -176,6 +176,7 @@ class GatewayLogger: CEPH_LOG_DIRECTORY = "/var/log/ceph/" MAX_LOG_FILE_SIZE_DEFAULT = 10 MAX_LOG_FILES_COUNT_DEFAULT = 20 + MAX_LOG_DIRECTORY_BACKUPS_DEFAULT = 10 NVME_LOG_DIR_PREFIX = "nvmeof-" NVME_LOG_FILE_NAME = "nvmeof-log" logger = None @@ -212,6 +213,7 @@ def __init__(self, config=None): log_files_rotation_enabled = config.getboolean_with_default("gateway", "log_files_rotation_enabled", True) max_log_file_size = config.getint_with_default("gateway", "max_log_file_size_in_mb", GatewayLogger.MAX_LOG_FILE_SIZE_DEFAULT) max_log_files_count = config.getint_with_default("gateway", "max_log_files_count", GatewayLogger.MAX_LOG_FILES_COUNT_DEFAULT) + max_log_directory_backups = config.getint_with_default("gateway", "max_log_directory_backups", GatewayLogger.MAX_LOG_DIRECTORY_BACKUPS_DEFAULT) log_level = config.get_with_default("gateway", "log_level", "info") else: verbose = True @@ -219,12 +221,13 @@ def __init__(self, config=None): log_files_rotation_enabled = False max_log_file_size = GatewayLogger.MAX_LOG_FILE_SIZE_DEFAULT max_log_files_count = GatewayLogger.MAX_LOG_FILES_COUNT_DEFAULT + max_log_directory_backups = GatewayLogger.MAX_LOG_DIRECTORY_BACKUPS_DEFAULT log_level = "info" self.handler = None logdir_ok = False if log_files_enabled: - GatewayLogger.rotate_backup_directories(self.log_directory, 5) + GatewayLogger.rotate_backup_directories(self.log_directory, max_log_directory_backups) if not log_files_rotation_enabled: max_log_file_size = 0 max_log_files_count = 0