Retry save and update IAM identity

https://github.com/chrislusf/seaweedfs/issues/2242
This commit is contained in:
Konstantin Lebedev 2021-08-11 17:53:48 +05:00
parent 5df38d610d
commit ec09966fd3
2 changed files with 9 additions and 2 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/s3api" "github.com/chrislusf/seaweedfs/weed/s3api"
. "github.com/chrislusf/seaweedfs/weed/s3api/s3_constants" . "github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
"github.com/chrislusf/seaweedfs/weed/s3api/s3err" "github.com/chrislusf/seaweedfs/weed/s3api/s3err"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/wdclient" "github.com/chrislusf/seaweedfs/weed/wdclient"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -103,7 +104,10 @@ func (iam IamS3ApiConfigure) PutS3ApiConfiguration(s3cfg *iam_pb.S3ApiConfigurat
iam.option.FilerGrpcAddress, iam.option.FilerGrpcAddress,
iam.option.GrpcDialOption, iam.option.GrpcDialOption,
func(client filer_pb.SeaweedFilerClient) error { func(client filer_pb.SeaweedFilerClient) error {
if err := filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile, buf.Bytes()); err != nil { err = util.Retry("saveIamIdentity", func() error {
return filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile, buf.Bytes())
})
if err != nil {
return err return err
} }
return nil return nil

View file

@ -23,7 +23,10 @@ func (s3a *S3ApiServer) subscribeMetaEvents(clientName string, prefix string, la
dir = message.NewParentPath dir = message.NewParentPath
} }
if dir == filer.IamConfigDirecotry && message.NewEntry.Name == filer.IamIdentityFile { if dir == filer.IamConfigDirecotry && message.NewEntry.Name == filer.IamIdentityFile {
if err := s3a.iam.loadS3ApiConfigurationFromBytes(message.NewEntry.Content); err != nil { err := util.Retry("updateIamIdentity", func() error {
return s3a.iam.loadS3ApiConfigurationFromBytes(message.NewEntry.Content)
})
if err != nil {
return err return err
} }
glog.V(0).Infof("updated %s/%s", filer.IamConfigDirecotry, filer.IamIdentityFile) glog.V(0).Infof("updated %s/%s", filer.IamConfigDirecotry, filer.IamIdentityFile)