From f87952a411339f2404cac2e771e6ae16644b97ca Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 11 Jul 2022 00:25:20 -0700 Subject: [PATCH 1/8] remove locks --- weed/iamapi/iamapi_management_handlers.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/weed/iamapi/iamapi_management_handlers.go b/weed/iamapi/iamapi_management_handlers.go index 488e92aa5..18cfe9f6e 100644 --- a/weed/iamapi/iamapi_management_handlers.go +++ b/weed/iamapi/iamapi_management_handlers.go @@ -412,14 +412,11 @@ func (iama *IamApiServer) DoActions(w http.ResponseWriter, r *http.Request) { return } values := r.PostForm - var s3cfgLock sync.RWMutex - s3cfgLock.RLock() s3cfg := &iam_pb.S3ApiConfiguration{} if err := iama.s3ApiConfig.GetS3ApiConfiguration(s3cfg); err != nil { s3err.WriteErrorResponse(w, r, s3err.ErrInternalError) return } - s3cfgLock.RUnlock() glog.V(4).Infof("DoActions: %+v", values) var response interface{} From 93ccc6e05ffaefd0e6cdd2141e43f72ccca582d1 Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 11 Jul 2022 00:50:07 -0700 Subject: [PATCH 2/8] 3.15 --- k8s/helm_charts2/Chart.yaml | 4 ++-- weed/util/constants.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s/helm_charts2/Chart.yaml b/k8s/helm_charts2/Chart.yaml index fe46c50a1..2ce8c3db9 100644 --- a/k8s/helm_charts2/Chart.yaml +++ b/k8s/helm_charts2/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 description: SeaweedFS name: seaweedfs -appVersion: "3.14" -version: "3.14" +appVersion: "3.15" +version: "3.15" diff --git a/weed/util/constants.go b/weed/util/constants.go index 7448fad62..8438624bf 100644 --- a/weed/util/constants.go +++ b/weed/util/constants.go @@ -5,7 +5,7 @@ import ( ) var ( - VERSION_NUMBER = fmt.Sprintf("%.02f", 3.14) + VERSION_NUMBER = fmt.Sprintf("%.02f", 3.15) VERSION = sizeLimit + " " + VERSION_NUMBER COMMIT = "" ) From 37578929d4f74ec9c8b610df691918b79cee79ca Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 11 Jul 2022 01:30:00 -0700 Subject: [PATCH 3/8] fix compilation --- weed/iamapi/iamapi_management_handlers.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/weed/iamapi/iamapi_management_handlers.go b/weed/iamapi/iamapi_management_handlers.go index 18cfe9f6e..994224688 100644 --- a/weed/iamapi/iamapi_management_handlers.go +++ b/weed/iamapi/iamapi_management_handlers.go @@ -495,9 +495,7 @@ func (iama *IamApiServer) DoActions(w http.ResponseWriter, r *http.Request) { return } if changed { - s3cfgLock.Lock() err := iama.s3ApiConfig.PutS3ApiConfiguration(s3cfg) - s3cfgLock.Unlock() if err != nil { writeIamErrorResponse(w, r, fmt.Errorf(iam.ErrCodeServiceFailureException), "", "", err) return From 7dbf19d09a137fb1b792459e2b6fb75e49fa8a3e Mon Sep 17 00:00:00 2001 From: guosj <515878133@qq.com> Date: Mon, 11 Jul 2022 16:38:41 +0800 Subject: [PATCH 4/8] refine PutUserPolicy --- weed/iamapi/iamapi_management_handlers.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/weed/iamapi/iamapi_management_handlers.go b/weed/iamapi/iamapi_management_handlers.go index 488e92aa5..fdd943b28 100644 --- a/weed/iamapi/iamapi_management_handlers.go +++ b/weed/iamapi/iamapi_management_handlers.go @@ -204,6 +204,7 @@ func (iama *IamApiServer) CreatePolicy(s3cfg *iam_pb.S3ApiConfiguration, values return resp, nil } +// https://docs.aws.amazon.com/IAM/latest/APIReference/API_PutUserPolicy.html func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values url.Values) (resp PutUserPolicyResponse, err error) { userName := values.Get("UserName") policyName := values.Get("PolicyName") @@ -212,15 +213,21 @@ func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values if err != nil { return PutUserPolicyResponse{}, err } + isFound := false policyDocuments[policyName] = &policyDocument actions := GetActions(&policyDocument) for _, ident := range s3cfg.Identities { - if userName == ident.Name { - for _, action := range actions { - ident.Actions = append(ident.Actions, action) - } - break + if userName != ident.Name { + continue } + isFound = true + for _, action := range actions { + ident.Actions = append(ident.Actions, action) + } + break + } + if !isFound { + return resp, fmt.Errorf("%s: the user with name %s cannot be found", iam.ErrCodeNoSuchEntityException, userName) } return resp, nil } From e098244afcf98ae64c5688128a681307bd9af03d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 15:33:00 +0000 Subject: [PATCH 5/8] Bump actions/setup-go from 3.2.0 to 3.2.1 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.2.0 to 3.2.1. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/b22fbbc2921299758641fab08929b4ac52b32923...84cbf8094393cdc5fe1fe1671ff2647332956b1a) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 48aee8768..8631cd9d2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Set up Go 1.x - uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # v2 + uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v2 with: go-version: ^1.13 id: go From 39e40664176d9a62fc53d49bef9e370dd448b16f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 15:33:38 +0000 Subject: [PATCH 6/8] Bump github.com/ydb-platform/ydb-go-sdk/v3 from 3.27.0 to 3.28.0 Bumps [github.com/ydb-platform/ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk) from 3.27.0 to 3.28.0. - [Release notes](https://github.com/ydb-platform/ydb-go-sdk/releases) - [Changelog](https://github.com/ydb-platform/ydb-go-sdk/blob/master/CHANGELOG.md) - [Commits](https://github.com/ydb-platform/ydb-go-sdk/compare/v3.27.0...v3.28.0) --- updated-dependencies: - dependency-name: github.com/ydb-platform/ydb-go-sdk/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e74d6f65..3b05d8ec3 100644 --- a/go.mod +++ b/go.mod @@ -154,7 +154,7 @@ require ( github.com/hashicorp/raft-boltdb v0.0.0-20220329195025-15018e9b97e0 github.com/tikv/client-go/v2 v2.0.1 github.com/ydb-platform/ydb-go-sdk-auth-environ v0.1.2 - github.com/ydb-platform/ydb-go-sdk/v3 v3.27.0 + github.com/ydb-platform/ydb-go-sdk/v3 v3.28.0 google.golang.org/grpc/security/advancedtls v0.0.0-20220622233350-5cdb09fa29c1 ) diff --git a/go.sum b/go.sum index b49ec509d..d72a3d1bb 100644 --- a/go.sum +++ b/go.sum @@ -924,8 +924,8 @@ github.com/ydb-platform/ydb-go-genproto v0.0.0-20220531094121-36ca6bddb9f7/go.mo github.com/ydb-platform/ydb-go-sdk-auth-environ v0.1.2 h1:EYSI1kulnHb0H0zt3yOw4cRj4ABMSMGwNe43D+fX7e4= github.com/ydb-platform/ydb-go-sdk-auth-environ v0.1.2/go.mod h1:Xfjce+VMU9yJVr1lj60yK2fFPWjB4jr/4cp3K7cjzi4= github.com/ydb-platform/ydb-go-sdk/v3 v3.25.3/go.mod h1:PFizF/vJsdAgEwjK3DVSBD52kdmRkWfSIS2q2pA+e88= -github.com/ydb-platform/ydb-go-sdk/v3 v3.27.0 h1:paSdC12yRI19Vv9ej6qAjUu2/r/WaW/rzsUogd+lg34= -github.com/ydb-platform/ydb-go-sdk/v3 v3.27.0/go.mod h1:vXjmbeEAWlkVE5/ym3XHhtnWk7aDGGqFMKrfgwbRUkQ= +github.com/ydb-platform/ydb-go-sdk/v3 v3.28.0 h1:F394Kkl+QPLrl0+fWpoSafdfgGqQCZOyzvXLxzVUWfs= +github.com/ydb-platform/ydb-go-sdk/v3 v3.28.0/go.mod h1:vXjmbeEAWlkVE5/ym3XHhtnWk7aDGGqFMKrfgwbRUkQ= github.com/ydb-platform/ydb-go-yc v0.8.3 h1:92UUUMsfvtMl6mho8eQ9lbkiPrF3a9CT+RrVRAKNRwo= github.com/ydb-platform/ydb-go-yc v0.8.3/go.mod h1:zUolAFGzJ5XG8uwiseTLr9Lapm7L7hdVdZgLSuv9FXE= github.com/ydb-platform/ydb-go-yc-metadata v0.5.2 h1:nMtixUijP0Z7iHJNT9fOL+dbmEzZxqU6Xk87ll7hqXg= From d9260f9d04d42730c3c34c225dc9513997efa0d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 15:33:51 +0000 Subject: [PATCH 7/8] Bump github.com/aws/aws-sdk-go from 1.44.47 to 1.44.51 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.47 to 1.44.51. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.47...v1.44.51) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e74d6f65..727097a68 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/Azure/azure-storage-blob-go v0.15.0 github.com/OneOfOne/xxhash v1.2.8 github.com/Shopify/sarama v1.34.1 - github.com/aws/aws-sdk-go v1.44.47 + github.com/aws/aws-sdk-go v1.44.51 github.com/beorn7/perks v1.0.1 // indirect github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 github.com/bwmarrin/snowflake v0.3.0 diff --git a/go.sum b/go.sum index b49ec509d..093148ebc 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.43.31/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.44.47 h1:uyiNvoR4wfZ8Bp4ghgbyzGFIg5knjZMUAd5S9ba9qNU= -github.com/aws/aws-sdk-go v1.44.47/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/aws/aws-sdk-go v1.44.51 h1:jO9hoLynZOrMM4dj0KjeKIK+c6PA+HQbKoHOkAEye2Y= +github.com/aws/aws-sdk-go v1.44.51/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aws/aws-sdk-go-v2 v1.16.2 h1:fqlCk6Iy3bnCumtrLz9r3mJ/2gUT0pJ0wLFVIdWh+JA= github.com/aws/aws-sdk-go-v2 v1.16.2/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1/go.mod h1:n8Bs1ElDD2wJ9kCRTczA83gYbBmjSwZp3umc6zF4EeM= From b3076909d1c7d3d55d49f7c9e1b28974beaa3a05 Mon Sep 17 00:00:00 2001 From: guosj <515878133@qq.com> Date: Tue, 12 Jul 2022 11:25:36 +0800 Subject: [PATCH 8/8] refactor code --- weed/iamapi/iamapi_management_handlers.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/weed/iamapi/iamapi_management_handlers.go b/weed/iamapi/iamapi_management_handlers.go index fdd943b28..561c6e770 100644 --- a/weed/iamapi/iamapi_management_handlers.go +++ b/weed/iamapi/iamapi_management_handlers.go @@ -213,23 +213,18 @@ func (iama *IamApiServer) PutUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values if err != nil { return PutUserPolicyResponse{}, err } - isFound := false policyDocuments[policyName] = &policyDocument actions := GetActions(&policyDocument) for _, ident := range s3cfg.Identities { if userName != ident.Name { continue } - isFound = true for _, action := range actions { ident.Actions = append(ident.Actions, action) } - break + return resp, nil } - if !isFound { - return resp, fmt.Errorf("%s: the user with name %s cannot be found", iam.ErrCodeNoSuchEntityException, userName) - } - return resp, nil + return resp, fmt.Errorf("%s: the user with name %s cannot be found", iam.ErrCodeNoSuchEntityException, userName) } func (iama *IamApiServer) GetUserPolicy(s3cfg *iam_pb.S3ApiConfiguration, values url.Values) (resp GetUserPolicyResponse, err error) {