From: Daniel Pivonka Date: Mon, 10 May 2021 14:20:38 +0000 (-0400) Subject: cephadm: manage cephadm log with logrotated X-Git-Tag: v17.1.0~1832^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6790b21bc5ba1e2ccdacefc7f067d5e760e6836d;p=ceph.git cephadm: manage cephadm log with logrotated Signed-off-by: Daniel Pivonka --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 8e26e35e841d..aa76beffe80e 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -213,11 +213,9 @@ logging_config = { }, 'log_file': { 'level': 'DEBUG', - 'class': 'logging.handlers.RotatingFileHandler', + 'class': 'logging.handlers.WatchedFileHandler', 'formatter': 'cephadm', 'filename': '%s/cephadm.log' % LOG_DIR, - 'maxBytes': 1024000, - 'backupCount': 1, } }, 'loggers': { @@ -5606,6 +5604,10 @@ def command_rm_cluster(ctx): # rm logrotate config call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/ceph-%s' % ctx.fsid]) + # rm cephadm logrotate config if last cluster on host + if not os.listdir(ctx.data_dir): + call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/cephadm']) + # rm sysctl settings sysctl_dir = Path(ctx.sysctl_dir) for p in sysctl_dir.glob(f'90-ceph-{ctx.fsid}-*.conf'): @@ -8208,6 +8210,18 @@ def cephadm_init(args: List[str]) -> Optional[CephadmContext]: dictConfig(logging_config) logger = logging.getLogger() + if not os.path.exists(ctx.logrotate_dir + '/cephadm'): + with open(ctx.logrotate_dir + '/cephadm', 'w') as f: + f.write("""# created by cephadm +/var/log/ceph/cephadm.log { + rotate 7 + daily + compress + missingok + notifempty +} +""") + if ctx.verbose: for handler in logger.handlers: if handler.name == 'console':