From d4b222e8c00a16b5cd43c52151ebcee2384d5ba7 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 7 Dec 2025 13:33:50 -0800 Subject: [PATCH] fix: initialize missing S3 options in filer to prevent nil pointer dereference Fixes #7644 When starting the S3 gateway from the filer, several S3Options fields were not being initialized, which could cause nil pointer dereferences during startup. This commit adds initialization for: - iamConfig: for advanced IAM configuration - metricsHttpPort: for Prometheus metrics endpoint - metricsHttpIp: for binding the metrics endpoint Also ensures metricsHttpIp defaults to bindIp when not explicitly set, matching the behavior of the standalone S3 server. This prevents the panic that was occurring in the s3.go:226 area when these pointer fields were accessed but never initialized. --- weed/command/filer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/command/filer.go b/weed/command/filer.go index 0e3154819..f76dfdd60 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -121,7 +121,10 @@ func init() { filerS3Options.tlsPrivateKey = cmdFiler.Flag.String("s3.key.file", "", "path to the TLS private key file") filerS3Options.tlsCertificate = cmdFiler.Flag.String("s3.cert.file", "", "path to the TLS certificate file") filerS3Options.config = cmdFiler.Flag.String("s3.config", "", "path to the config file") + filerS3Options.iamConfig = cmdFiler.Flag.String("s3.iam.config", "", "path to the advanced IAM config file") filerS3Options.auditLogConfig = cmdFiler.Flag.String("s3.auditLogConfig", "", "path to the audit log config file") + filerS3Options.metricsHttpPort = cmdFiler.Flag.Int("s3.metricsPort", 0, "Prometheus metrics listen port") + filerS3Options.metricsHttpIp = cmdFiler.Flag.String("s3.metricsIp", "", "metrics listen ip. If empty, default to same as -s3.ip.bind option.") cmdFiler.Flag.Bool("s3.allowEmptyFolder", true, "deprecated, ignored. Empty folder cleanup is now automatic.") filerS3Options.allowDeleteBucketNotEmpty = cmdFiler.Flag.Bool("s3.allowDeleteBucketNotEmpty", true, "allow recursive deleting all entries along with bucket") filerS3Options.localSocket = cmdFiler.Flag.String("s3.localSocket", "", "default to /tmp/seaweedfs-s3-.sock") @@ -229,6 +232,10 @@ func runFiler(cmd *Command, args []string) bool { if *f.dataCenter != "" && *filerS3Options.dataCenter == "" { filerS3Options.dataCenter = f.dataCenter } + // Set S3 metrics IP based on bind IP if not explicitly set + if *filerS3Options.metricsHttpIp == "" { + filerS3Options.metricsHttpIp = filerS3Options.bindIp + } go func(delay time.Duration) { time.Sleep(delay * time.Second) filerS3Options.startS3Server()