Browse Source

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.
pull/7550/head
Chris Lu 4 days ago
parent
commit
9346e6bc25
  1. 19
      weed/s3api/s3api_server.go

19
weed/s3api/s3api_server.go

@ -123,22 +123,21 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl
if option.IamConfig != "" { if option.IamConfig != "" {
glog.V(1).Infof("Loading advanced IAM configuration from: %s", 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 { 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 { if err != nil {
glog.Errorf("Failed to load IAM configuration: %v", err) glog.Errorf("Failed to load IAM configuration: %v", err)
} else { } else {
// Create S3 IAM integration with the loaded IAM manager // 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) s3iam := NewS3IAMIntegration(iamManager, filerAddr)
// Set IAM integration in server // Set IAM integration in server

Loading…
Cancel
Save