From c42244f7e6153c69be5e517cbf27afef384aaac7 Mon Sep 17 00:00:00 2001 From: Yibo Zhuang Date: Tue, 1 Sep 2026 13:34:14 -0700 Subject: [PATCH] Bound worker log retention (#476) Keep at most five rotated worker log files for up to fourteen days and compress them. Retain the existing 100 MB rotation threshold so long-running workers do not accumulate an unlimited number of log backups. Co-authored-by: kroo-oai --- internal/command/worker/run.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/command/worker/run.go b/internal/command/worker/run.go index 042f250..e1a1ec6 100644 --- a/internal/command/worker/run.go +++ b/internal/command/worker/run.go @@ -261,6 +261,12 @@ func readBootstrapToken() (string, error) { } func createLogger() (*zap.Logger, error) { + const ( + maxLogSizeMB = 100 + maxLogBackups = 5 + maxLogAgeDays = 14 + ) + level := zap.InfoLevel if debug { level = zap.DebugLevel @@ -274,8 +280,11 @@ func createLogger() (*zap.Logger, error) { } logFileWriter := zapcore.AddSync(&lumberjack.Logger{ - Filename: logFilePath, - MaxSize: 100, // megabytes + Filename: logFilePath, + MaxSize: maxLogSizeMB, + MaxBackups: maxLogBackups, + MaxAge: maxLogAgeDays, + Compress: true, }) core := zapcore.NewCore( zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),