Skip to content

Commit

Permalink
fix: `TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPublicl…
Browse files Browse the repository at this point in the history
…yAccessible` you need a snapshot to be able to update the capacity. During the creation of this `conflictExceptions` occur. We already retry on the deletion for it so it makes sense for update aswell.

make testacc TESTARGS='-run=TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible' PKG=redshiftserverless
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.6 test ./internal/service/redshiftserverless/... -v -count 1 -parallel 20  -run=TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible -timeout 360m
=== RUN   TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible
=== PAUSE TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible
=== CONT  TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible
--- PASS: TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible (2002.95s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/redshiftserverless 2007.594s
  • Loading branch information
DanielRieske committed Aug 13, 2024
1 parent 4f257d1 commit 20ba336
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/service/redshiftserverless/workgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,14 @@ func resourceWorkgroupDelete(ctx context.Context, d *schema.ResourceData, meta i
}

func updateWorkgroup(ctx context.Context, conn *redshiftserverless.Client, input *redshiftserverless.UpdateWorkgroupInput, timeout time.Duration) error {
_, err := tfresource.RetryWhenIsAErrorMessageContains[*awstypes.ConflictException](ctx, workgroupUpdatedTimeout,
func() (interface{}, error) {
return conn.UpdateWorkgroup(ctx, input)
},
// "ConflictException: There is an operation running on the workgroup. Try to update it later."
"operation running")

name := aws.ToString(input.WorkgroupName)
_, err := conn.UpdateWorkgroup(ctx, input)

if err != nil {
return fmt.Errorf("updating Redshift Serverless Workgroup (%s): %w", name, err)
Expand All @@ -491,6 +497,7 @@ func updateWorkgroup(ctx context.Context, conn *redshiftserverless.Client, input

const (
workgroupDeletedTimeout = 10 * time.Minute
workgroupUpdatedTimeout = 10 * time.Minute
)

func findWorkgroupByName(ctx context.Context, conn *redshiftserverless.Client, name string) (*awstypes.Workgroup, error) {
Expand Down
6 changes: 6 additions & 0 deletions internal/service/redshiftserverless/workgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ resource "aws_redshiftserverless_workgroup" "test" {
workgroup_name = %[1]q
base_capacity = %[2]d
}
resource "aws_redshiftserverless_snapshot" "test" {
namespace_name = aws_redshiftserverless_workgroup.test.namespace_name
snapshot_name = %[1]q
retention_period = 10
}
`, rName, baseCapacity)
}

Expand Down

0 comments on commit 20ba336

Please sign in to comment.