Track current active filer in FilerClient for better HA

Add GetCurrentFiler() method to FilerClient that returns the currently
active filer based on the filerIndex which is updated on successful
operations. This provides better availability than always using the
first filer.

Changes:
- Add FilerClient.GetCurrentFiler() method that returns current active filer
- Update S3ApiServer.getFilerAddress() to use FilerClient's current filer
- Add fallback to first filer if FilerClient not yet initialized
- Document IAM limitation (doesn't have FilerClient access)

Benefits:
- Single-filer operations (URLs, ReadFilerConf, etc.) now use the
  currently active/healthy filer
- Better distribution and failover behavior
- FilerClient's round-robin and health tracking automatically
  determines which filer to use
This commit is contained in:
Chris Lu committed 2025-11-25 20:19:01 -08:00
1 parent 7611f05f37
commit ee6054700f
3 files changed
+29 -4

No files matched your search

+7 -3
View File
@@ -185,10 +185,14 @@ func NewS3ApiServerWithStore(router *mux.Router, option *S3ApiServerOption, expl
return s3ApiServer, nil
}
// getFilerAddress returns the current filer address to use
// For operations that need a single address, returns the first one
// The underlying FilerClient handles failover automatically
// getFilerAddress returns the current active filer address
// Uses FilerClient's tracked current filer which is updated on successful operations
// This provides better availability than always using the first filer
func (s3a *S3ApiServer) getFilerAddress() pb.ServerAddress {
if s3a.filerClient != nil {
return s3a.filerClient.GetCurrentFiler()
}
// Fallback to first filer if filerClient not initialized
if len(s3a.option.Filers) > 0 {
return s3a.option.Filers[0]
}