From ec09966fd3955b466cfa8f3a3945133226f6a3fd Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Wed, 11 Aug 2021 17:53:48 +0500 Subject: [PATCH 1/2] Retry save and update IAM identity https://github.com/chrislusf/seaweedfs/issues/2242 --- weed/iamapi/iamapi_server.go | 6 +++++- weed/s3api/auth_credentials_subscribe.go | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/weed/iamapi/iamapi_server.go b/weed/iamapi/iamapi_server.go index 037594165..ec718bd41 100644 --- a/weed/iamapi/iamapi_server.go +++ b/weed/iamapi/iamapi_server.go @@ -13,6 +13,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/s3api" . "github.com/chrislusf/seaweedfs/weed/s3api/s3_constants" "github.com/chrislusf/seaweedfs/weed/s3api/s3err" + "github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/wdclient" "github.com/gorilla/mux" "google.golang.org/grpc" @@ -103,7 +104,10 @@ func (iam IamS3ApiConfigure) PutS3ApiConfiguration(s3cfg *iam_pb.S3ApiConfigurat iam.option.FilerGrpcAddress, iam.option.GrpcDialOption, 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 nil diff --git a/weed/s3api/auth_credentials_subscribe.go b/weed/s3api/auth_credentials_subscribe.go index 05cce632a..894faa614 100644 --- a/weed/s3api/auth_credentials_subscribe.go +++ b/weed/s3api/auth_credentials_subscribe.go @@ -23,7 +23,10 @@ func (s3a *S3ApiServer) subscribeMetaEvents(clientName string, prefix string, la dir = message.NewParentPath } 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 } glog.V(0).Infof("updated %s/%s", filer.IamConfigDirecotry, filer.IamIdentityFile) From f0afd35eec3d0a860b9b205709574f55e321a385 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Wed, 11 Aug 2021 19:29:04 +0500 Subject: [PATCH 2/2] Retry save and update IAM identity https://github.com/chrislusf/seaweedfs/issues/2242 --- weed/s3api/auth_credentials_subscribe.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/weed/s3api/auth_credentials_subscribe.go b/weed/s3api/auth_credentials_subscribe.go index 894faa614..05cce632a 100644 --- a/weed/s3api/auth_credentials_subscribe.go +++ b/weed/s3api/auth_credentials_subscribe.go @@ -23,10 +23,7 @@ func (s3a *S3ApiServer) subscribeMetaEvents(clientName string, prefix string, la dir = message.NewParentPath } if dir == filer.IamConfigDirecotry && message.NewEntry.Name == filer.IamIdentityFile { - err := util.Retry("updateIamIdentity", func() error { - return s3a.iam.loadS3ApiConfigurationFromBytes(message.NewEntry.Content) - }) - if err != nil { + if err := s3a.iam.loadS3ApiConfigurationFromBytes(message.NewEntry.Content); err != nil { return err } glog.V(0).Infof("updated %s/%s", filer.IamConfigDirecotry, filer.IamIdentityFile)