diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-12-07 19:56:05 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-07 19:56:05 -0800 |
| commit | a9b3be416bb9deae3eecdbabef0ca3d4f8a11feb (patch) | |
| tree | 9136cd5ce06b95481f6c911c0cd44f378c4fe737 /weed/command | |
| parent | 5d53edb93b8e955905209570d1132e06c8ccd6e0 (diff) | |
| download | seaweedfs-a9b3be416bb9deae3eecdbabef0ca3d4f8a11feb.tar.xz seaweedfs-a9b3be416bb9deae3eecdbabef0ca3d4f8a11feb.zip | |
fix: initialize missing S3 options in filer to prevent nil pointer dereference (#7646)
* 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.
* fix: copy value instead of pointer for metricsHttpIp default
Address review comment to avoid pointer aliasing. Copy the value
instead of the pointer to prevent unexpected side effects if the
bindIp value is modified later.
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/filer.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/weed/command/filer.go b/weed/command/filer.go index 0e3154819..bce0a941e 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-<port>.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() |
