From d982ad68b208379dd8f6b0495a798dbb334a08a4 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Wed, 8 Jan 2025 15:04:09 -0500 Subject: [PATCH] r/aws_apigatewayv2: additional `ConflictException` retry logic This change adds an additional step to the `apigatewayv2` service client retry logic to check for `ConflictException` error responses based solely on the message content. This is intended to address cases where the error is not serialized into the higher level `types.ConflictException` defined as the service package level (which the existing logic expects). Local testing of the configuration provided in the linked issue confirmed this additional logic prevents the intermittent failures observed during destruction of large numbers of routes in parallel. ```console % make testacc PKG=apigatewayv2 TESTS=TestAccAPIGatewayV2Route_ make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.23.3 test ./internal/service/apigatewayv2/... -v -count 1 -parallel 20 -run='TestAccAPIGatewayV2Route_' -timeout 360m 2025/01/08 15:06:20 Initializing Terraform AWS Provider... --- PASS: TestAccAPIGatewayV2Route_disappears (17.18s) --- PASS: TestAccAPIGatewayV2Route_basic (18.81s) --- PASS: TestAccAPIGatewayV2Route_target (19.62s) --- PASS: TestAccAPIGatewayV2Route_model (19.76s) --- PASS: TestAccAPIGatewayV2Route_updateRouteKey (27.79s) --- PASS: TestAccAPIGatewayV2Route_requestParameters (36.06s) --- PASS: TestAccAPIGatewayV2Route_simpleAttributes (36.27s) --- PASS: TestAccAPIGatewayV2Route_authorizer (53.29s) --- PASS: TestAccAPIGatewayV2Route_jwtAuthorization (53.34s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/apigatewayv2 59.735s ``` --- .changelog/40840.txt | 6 ++++++ internal/service/apigatewayv2/service_package.go | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 .changelog/40840.txt diff --git a/.changelog/40840.txt b/.changelog/40840.txt new file mode 100644 index 00000000000..7c3d646cb49 --- /dev/null +++ b/.changelog/40840.txt @@ -0,0 +1,6 @@ +```release-note:bug +resource/aws_apigatewayv2_route: Fix retry handling of `ConflictException` error responses +``` +```release-note:note +provider: The retry handling in the `apigatewayv2` client has been updated to more extensively match `ConflictException` error responses. This change should be transparent to users, but if any unexpected changes in behavior with `apigatewayv2` resources occur following an upgrade to this release, please open a bug report. +``` diff --git a/internal/service/apigatewayv2/service_package.go b/internal/service/apigatewayv2/service_package.go index da6f2488467..b3bf75066e6 100644 --- a/internal/service/apigatewayv2/service_package.go +++ b/internal/service/apigatewayv2/service_package.go @@ -27,6 +27,13 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( if errs.IsAErrorMessageContains[*awstypes.ConflictException](err, "try again later") { return aws.TrueTernary } + // In some instances, ConflictException error responses have been observed as + // a *smithy.OperationError type (not an *awstypes.ConflictException), which + // can't be handled via errs.IsAErrorMessageContains. Instead we fall back + // to a simple match on the message contents. + if errs.Contains(err, "Unable to complete operation due to concurrent modification. Please try again later.") { + return aws.TrueTernary + } return aws.UnknownTernary // Delegate to configured Retryer. })) },