Skip to content

Commit

Permalink
Merge pull request #2054 from lbowe/s3-tagging-fix
Browse files Browse the repository at this point in the history
fix(S3): Add check for S3 tagging api error code when empty TagSet
  • Loading branch information
MisterMX authored May 2, 2024
2 parents a91527e + fe680d2 commit fbdd828
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/s3/bucket/taggingConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (in *TaggingConfigurationClient) CacheBucketTaggingOutput(ctx context.Conte
if in.cache.getBucketTaggingOutput == nil {
external, err := in.client.GetBucketTagging(ctx, &awss3.GetBucketTaggingInput{Bucket: bucketName})
if err != nil {
if s3.TaggingNotFound(err) {
return &awss3.GetBucketTaggingOutput{TagSet: nil}, nil
}
return external, err
}
in.cache.getBucketTaggingOutput = external
Expand Down
16 changes: 16 additions & 0 deletions pkg/controller/s3/bucket/taggingConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,22 @@ func TestTaggingCreateOrUpdate(t *testing.T) {
err: nil,
},
},
"SuccessfulCreateNoExistingTags": {
args: args{
b: s3testing.Bucket(s3testing.WithTaggingConfig(generateTaggingConfig())),
cl: NewTaggingConfigurationClient(fake.MockBucketClient{
MockPutBucketTagging: func(ctx context.Context, input *s3.PutBucketTaggingInput, opts []func(*s3.Options)) (*s3.PutBucketTaggingOutput, error) {
return &s3.PutBucketTaggingOutput{}, nil
},
MockGetBucketTagging: func(ctx context.Context, input *s3.GetBucketTaggingInput, opts []func(*s3.Options)) (*s3.GetBucketTaggingOutput, error) {
return nil, &smithy.GenericAPIError{Code: clientss3.TaggingNotFoundErrCode}
},
}),
},
want: want{
err: nil,
},
},
}

for name, tc := range cases {
Expand Down

0 comments on commit fbdd828

Please sign in to comment.