From 9346e6bc25ea3d403038d42ea08d1ba003a3bbb8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 25 Nov 2025 20:14:57 -0800 Subject: [PATCH] Fix IAM manager initialization: remove code duplication, add TODO for HA Addresses review comment on s3api_server.go:145 Changes: - Remove duplicate code for getting first filer address - Extract filerAddr variable once and reuse - Add TODO comment documenting the HA limitation for IAM manager - Document that loadIAMManagerFromConfig and NewS3IAMIntegration need updates to support multiple filers for full HA Note: This is a known limitation when using filer-backed IAM stores. The interfaces need to be updated to accept multiple filer addresses. For now, documenting this limitation clearly. --- weed/s3api/s3api_server.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index bb54f543b..4b658525a 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -123,22 +123,21 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl if option.IamConfig != "" { glog.V(1).Infof("Loading advanced IAM configuration from: %s", option.IamConfig) + // Note: IAM manager and S3IAMIntegration currently use only the first filer address + // TODO: Update loadIAMManagerFromConfig and NewS3IAMIntegration to support multiple filers + // for full HA. This is a known limitation for filer-backed IAM stores. + filerAddr := "" + if len(option.Filers) > 0 { + filerAddr = string(option.Filers[0]) + } + iamManager, err := loadIAMManagerFromConfig(option.IamConfig, func() string { - // Use the first filer address for IAM - if len(option.Filers) > 0 { - return string(option.Filers[0]) - } - return "" + return filerAddr }) if err != nil { glog.Errorf("Failed to load IAM configuration: %v", err) } else { // Create S3 IAM integration with the loaded IAM manager - // Use the first filer address for IAM - filerAddr := "" - if len(option.Filers) > 0 { - filerAddr = string(option.Filers[0]) - } s3iam := NewS3IAMIntegration(iamManager, filerAddr) // Set IAM integration in server