Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The aws_appmesh_virtual_service throws "produced an unexpected new value for was present, but now absent" error. #15084

Closed
mkielar opened this issue Sep 9, 2020 · 4 comments · Fixed by #18529
Assignees
Labels
bug Addresses a defect in current functionality. service/appmesh Issues and PRs that pertain to the appmesh service.
Milestone

Comments

@mkielar
Copy link
Contributor

mkielar commented Sep 9, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.12.29
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "random" (hashicorp/random) 2.3.0...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.70.0...
- Downloading plugin for provider "external" (hashicorp/external) 1.2.0...
- Downloading plugin for provider "null" (hashicorp/null) 2.1.2...

Affected Resource(s)

  • aws_appmesh_virtual_service

Terraform Configuration Files

resource "aws_appmesh_virtual_service" "vs" {

  mesh_name = var.appmesh.name

  name = "${local.name}.${var.service_discovery.namespace_name}"

  spec {
    provider {
      virtual_router {
        virtual_router_name = aws_appmesh_virtual_router.vr.name
      }
    }
  }
}

Debug Output

On first run, terraform fails like this:

Error: Provider produced inconsistent result after apply
When applying changes to
module.[MASKED].module.template.aws_appmesh_virtual_service.vs,
provider "registry.terraform.io/-/aws" produced an unexpected new value for
was present, but now absent.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Then on retry, it fails like this:

Error: error creating App Mesh virtual service: ConflictException: VirtualService with name dev-i270-sst-template.dev-i270.[MASKED].local already exists with different clientRequestToken C1833BA9-42A4-48D3-B855-243582FC4B62
  on .terraform/modules/[MASKED].template/terraform/modules/ecs/service_blue_green/appmesh.tf line 105, in resource "aws_appmesh_virtual_service" "vs":
 105: resource "aws_appmesh_virtual_service" "vs" {

It appears as if terraform (and AWS) create the resource properly, but terraform fails to acknowledge the fact and does not reflect that fact the statefile. Then, another run of terraform apply does not see that resource in the statefile, and tries to create it again - failing, because it already exists.

Panic Output

Expected Behavior

The resources should've been created and terraform should not fail.

Actual Behavior

Terraform fails (ther first time) because of what it says is a bug in the provider. Then if fails the second time because the resources actually gets created but it's not reflected in the state file.

Steps to Reproduce

  1. terraform apply

Important Factoids

The error appears randomly. We're frequently creating and destroying resources as part of out CICD pipeline (entire dev environments live for just a few days and are destroyed together with git branches being merged) and this happens once or twice a month with no distinguishable pattern. Therefore, we have not been able to reproduce this issue with debug logging enabled and only have the logs as attached.

@ghost ghost added the service/appmesh Issues and PRs that pertain to the appmesh service. label Sep 9, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 9, 2020
@ewbankkit
Copy link
Contributor

This is most likely an "eventual consistency" issue - After creation the virtual service is read back but the API returns a NotFoundException error code.
The solution would be to add a retry in resourceAwsAppmeshVirtualServiceCreate() to ensure that the virtual service can be read back.

@mkielar
Copy link
Contributor Author

mkielar commented Jan 27, 2021

Just today, again, this time Virtual Node, not Service:

Error: Provider produced inconsistent result after apply
When applying changes to
module.[MASKED].module.[MASKED].aws_appmesh_virtual_node.vn["blue"],
provider "registry.terraform.io/hashicorp/aws" produced an unexpected new
value: Root resource was present, but now absent.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
Terraform v0.13.3
- Using hashicorp/local v1.4.0 from the shared cache directory
- Using hashicorp/null v2.1.2 from the shared cache directory
- Using hashicorp/random v2.3.1 from the shared cache directory
- Using hashicorp/tls v3.0.0 from the shared cache directory
- Using hashicorp/aws v3.25.0 from the shared cache directory
- Using hashicorp/external v1.2.0 from the shared cache directory

bflad added a commit that referenced this issue Apr 1, 2021
…ources

Reference: #15084
Reference: #16796
Reference: https://blog.envoyproxy.io/embracing-eventual-consistency-in-soa-networking-32a5ee5d443d

Output from acceptance testing in AWS Commercial:

```
--- FAIL: TestAccAWSAppmesh_serial (1654.08s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualRouter (64.89s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualRouter/basic (27.55s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualRouter/tags (37.34s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualService (102.18s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualService/virtualNode (30.51s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualService/virtualRouter (27.91s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualService/tags (43.76s)
    --- PASS: TestAccAWSAppmesh_serial/GatewayRoute (180.76s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/httpRoute (31.38s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/http2Route (30.54s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/tags (45.18s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/basic (18.19s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/disappears (14.95s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/grpcRoute (40.53s)
    --- PASS: TestAccAWSAppmesh_serial/Mesh (73.44s)
        --- PASS: TestAccAWSAppmesh_serial/Mesh/basic (12.91s)
        --- PASS: TestAccAWSAppmesh_serial/Mesh/egressFilter (29.35s)
        --- PASS: TestAccAWSAppmesh_serial/Mesh/tags (31.18s)
    --- FAIL: TestAccAWSAppmesh_serial/Route (429.26s)
        --- PASS: TestAccAWSAppmesh_serial/Route/httpRoute (43.23s)
        --- PASS: TestAccAWSAppmesh_serial/Route/tcpRoute (42.71s)
        --- PASS: TestAccAWSAppmesh_serial/Route/tcpRouteTimeout (30.21s)
        --- PASS: TestAccAWSAppmesh_serial/Route/grpcRouteEmptyMatch (17.81s)
        --- PASS: TestAccAWSAppmesh_serial/Route/grpcRouteTimeout (31.13s)
        --- PASS: TestAccAWSAppmesh_serial/Route/http2RouteTimeout (31.08s)
        --- PASS: TestAccAWSAppmesh_serial/Route/httpRetryPolicy (32.21s)
        --- PASS: TestAccAWSAppmesh_serial/Route/routePriority (31.77s)
        --- PASS: TestAccAWSAppmesh_serial/Route/tags (44.91s)
        --- PASS: TestAccAWSAppmesh_serial/Route/grpcRoute (54.42s)
        --- PASS: TestAccAWSAppmesh_serial/Route/http2Route (30.70s)
        --- FAIL: TestAccAWSAppmesh_serial/Route/httpHeader (8.24s) # #18528
        --- PASS: TestAccAWSAppmesh_serial/Route/httpRouteTimeout (30.84s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualGateway (285.66s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerConnectionPool (26.22s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerHealthChecks (26.25s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerTls (70.19s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/basic (17.09s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/disappears (12.66s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/backendDefaultsCertificate (15.85s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/tags (38.11s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/backendDefaults (26.15s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerValidation (26.61s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/logging (26.53s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualNode (517.90s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerOutlierDetection (26.74s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerTimeout (26.37s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/tags (38.61s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/disappears (12.41s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendClientPolicyFile (26.83s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/cloudMapServiceDiscovery (99.43s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/basic (15.51s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendClientPolicyAcm (50.89s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerTls (69.86s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendDefaults (27.28s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendDefaultsCertificate (15.92s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerValidation (26.70s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerConnectionPool (28.32s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerHealthChecks (26.63s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/logging (26.40s)
```
bflad added a commit that referenced this issue Apr 2, 2021
…ources (#18529)

* service/appmesh: Handle read-after-create eventual consistency in resources

Reference: #15084
Reference: #16796
Reference: https://blog.envoyproxy.io/embracing-eventual-consistency-in-soa-networking-32a5ee5d443d

Output from acceptance testing in AWS Commercial:

```
--- FAIL: TestAccAWSAppmesh_serial (1654.08s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualRouter (64.89s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualRouter/basic (27.55s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualRouter/tags (37.34s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualService (102.18s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualService/virtualNode (30.51s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualService/virtualRouter (27.91s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualService/tags (43.76s)
    --- PASS: TestAccAWSAppmesh_serial/GatewayRoute (180.76s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/httpRoute (31.38s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/http2Route (30.54s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/tags (45.18s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/basic (18.19s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/disappears (14.95s)
        --- PASS: TestAccAWSAppmesh_serial/GatewayRoute/grpcRoute (40.53s)
    --- PASS: TestAccAWSAppmesh_serial/Mesh (73.44s)
        --- PASS: TestAccAWSAppmesh_serial/Mesh/basic (12.91s)
        --- PASS: TestAccAWSAppmesh_serial/Mesh/egressFilter (29.35s)
        --- PASS: TestAccAWSAppmesh_serial/Mesh/tags (31.18s)
    --- FAIL: TestAccAWSAppmesh_serial/Route (429.26s)
        --- PASS: TestAccAWSAppmesh_serial/Route/httpRoute (43.23s)
        --- PASS: TestAccAWSAppmesh_serial/Route/tcpRoute (42.71s)
        --- PASS: TestAccAWSAppmesh_serial/Route/tcpRouteTimeout (30.21s)
        --- PASS: TestAccAWSAppmesh_serial/Route/grpcRouteEmptyMatch (17.81s)
        --- PASS: TestAccAWSAppmesh_serial/Route/grpcRouteTimeout (31.13s)
        --- PASS: TestAccAWSAppmesh_serial/Route/http2RouteTimeout (31.08s)
        --- PASS: TestAccAWSAppmesh_serial/Route/httpRetryPolicy (32.21s)
        --- PASS: TestAccAWSAppmesh_serial/Route/routePriority (31.77s)
        --- PASS: TestAccAWSAppmesh_serial/Route/tags (44.91s)
        --- PASS: TestAccAWSAppmesh_serial/Route/grpcRoute (54.42s)
        --- PASS: TestAccAWSAppmesh_serial/Route/http2Route (30.70s)
        --- FAIL: TestAccAWSAppmesh_serial/Route/httpHeader (8.24s) # #18528
        --- PASS: TestAccAWSAppmesh_serial/Route/httpRouteTimeout (30.84s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualGateway (285.66s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerConnectionPool (26.22s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerHealthChecks (26.25s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerTls (70.19s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/basic (17.09s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/disappears (12.66s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/backendDefaultsCertificate (15.85s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/tags (38.11s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/backendDefaults (26.15s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/listenerValidation (26.61s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualGateway/logging (26.53s)
    --- PASS: TestAccAWSAppmesh_serial/VirtualNode (517.90s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerOutlierDetection (26.74s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerTimeout (26.37s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/tags (38.61s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/disappears (12.41s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendClientPolicyFile (26.83s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/cloudMapServiceDiscovery (99.43s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/basic (15.51s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendClientPolicyAcm (50.89s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerTls (69.86s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendDefaults (27.28s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/backendDefaultsCertificate (15.92s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerValidation (26.70s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerConnectionPool (28.32s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/listenerHealthChecks (26.63s)
        --- PASS: TestAccAWSAppmesh_serial/VirtualNode/logging (26.40s)
```

* Update CHANGELOG for #18529

* tests/resource/aws_appmesh_route: Fix httpHeader test configuration

Reference: #18528
Reference: https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HttpRouteMatch.html#appmesh-Type-HttpRouteMatch-scheme

Previously:

```
=== RUN   TestAccAWSAppmesh_serial/Route/httpHeader
    resource_aws_appmesh_route_test.go:1084: Step 1/3 error: Error running apply: exit status 1

        Error: error creating App Mesh route: ForbiddenException: Scheme matching in HTTP routes is not supported.

          on terraform_plugin_test.tf line 34, in resource "aws_appmesh_route" "test":
          34: resource "aws_appmesh_route" "test" {
```

Output from acceptance test:

```
        --- PASS: TestAccAWSAppmesh_serial/Route/httpHeader (31.41s)
```
@github-actions github-actions bot added this to the v3.36.0 milestone Apr 2, 2021
@ghost
Copy link

ghost commented Apr 9, 2021

This has been released in version 3.36.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented May 3, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/appmesh Issues and PRs that pertain to the appmesh service.
Projects
None yet
2 participants