hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.36k stars 1.75k forks source link

Failing test(s): TestAccComputeResizeRequest_computeMigResizeRequestExample #19917

Open SarahFrench opened 1 month ago

SarahFrench commented 1 month ago

Impacted tests

Affected Resource(s)

Failure rates

The test only fails if the test environment causes the resize to fail, but in situations where the resize fails this panic will always occur. I'll label the issue as 100% failure.

Message(s)

Panic from flattenComputeResizeRequestStatusLastAttemptErrorErrors

See builds where this happened:

panic: interface conversion: interface {} is []interface {}, not map[string]interface {}

    goroutine 1162 [running]:
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.flattenComputeResizeRequestStatusLastAttemptErrorErrors({0x417a520?, 0xc0018cb578?}, 0x4b7a7d4?, 0x6?)
      /foo/google-beta/services/compute/resource_compute_resize_request.go:1049 +0x2f8
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.flattenComputeResizeRequestStatusLastAttemptError({0x446e9c0?, 0xc001bef4a0}, 0x4b79346?, 0x5?)
      /foo/google-beta/services/compute/resource_compute_resize_request.go:1042 +0xa5
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.flattenComputeResizeRequestStatusLastAttempt({0x446e9c0?, 0xc001bef470}, 0x4b87240?, 0xb?)
      /foo/google-beta/services/compute/resource_compute_resize_request.go:1029 +0xa5
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.flattenComputeResizeRequestStatus({0x446e9c0?, 0xc001bef440}, 0x4b7a65a?, 0x6?)
      /foo/google-beta/services/compute/resource_compute_resize_request.go:792 +0x133
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.resourceComputeResizeRequestRead(0xc00240ee00, {0x4b46640?, 0xc001b83800})
      /foo/google-beta/services/compute/resource_compute_resize_request.go:609 +0x833
    github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.resourceComputeResizeRequestCreate(0xc00240ee00, {0x4b46640?, 0xc001b83800?})
      /foo/google-beta/services/compute/resource_compute_resize_request.go:546 +0xee5
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x55e1640?, {0x55e1640?, 0xc001bbb1a0?}, 0xd?, {0x4b46640?, 0xc001b83800?})
      /foo/go/1.21.13/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:766 +0x163
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000a72c40, {0x55e1640, 0xc001bbb1a0}, 0xc0018d92b0, 0xc002f1bf00, {0x4b46640, 0xc001b83800})
      /foo/go/1.21.13/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:909 +0xa89
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc001f82b28, {0x55e1640?, 0xc001bbb110?}, 0xc001234d70)
      /foo/go/1.21.13/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xdbc
    github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ApplyResourceChange(0x55e1678?, {0x55e1640?, 0xc001bbae70?}, 0xc001234d70)
      /foo/go/1.21.13/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.15.0/tf5muxserver/mux_server_ApplyResourceChange.go:36 +0x193
    github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00217c960, {0x55e1640?, 0xc001bba660?}, 0xc0018b8690)
      /foo/go/1.21.13/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:865 +0x3d0
    github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x4ade900?, 0xc00217c960}, {0x55e1640, 0xc001bba660}, 0xc002f1bc00, 0x0)
      /foo/go/1.21.13/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x169
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000d9c00, {0x55e1640, 0xc001bba5d0}, {0x55ed968, 0xc0001cc780}, 0xc0018c4a20, 0xc001cee8a0, 0x7964318, 0x0)
      /foo/go/1.21.13/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1379 +0xe23
    google.golang.org/grpc.(*Server).handleStream(0xc0000d9c00, {0x55ed968, 0xc0001cc780}, 0xc0018c4a20)
      /foo/go/1.21.13/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1790 +0x1016
    google.golang.org/grpc.(*Server).serveStreams.func2.1()
      /foo/go/1.21.13/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1029 +0x8b
    created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 700
      /foo/go/1.21.13/pkg/mod/google.golang.org/grpc@v1.65.0/server.go:1040 +0x135

Nightly build test history

b/374273746

SarahFrench commented 1 month ago

From one of the builds I link above under Message(s) I can see this is the API's response that's involved in the panic:

---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Thu, 17 Oct 2024 11:28:24 GMT
Etag: FSCrXwsrOtLCc3VHT4XIoalk4Sc=/WsmFvTzbKjzpmuH1ByKk-49cc_E=
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
  "kind": "compute#instanceGroupManagerResizeRequest",
  "id": "9113303207974357537",
  "creationTimestamp": "2024-10-17T04:28:14.344-07:00",
  "name": "tf-test-a3-dwsgbbsro3e6z",
  "description": "Test resize request resource",
  "zone": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/us-central1-a",
  "resizeBy": 2,
  "requestedRunDuration": {
    "seconds": "14400",
    "nanos": 0
  },
  "state": "ACCEPTED",
  "status": {
    "lastAttempt": {
      "error": {
        "errors": [
          {
            "code": "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS",
            "message": "Waiting for resources. Currently there are not enough resources available to fulfill the request."
          }
        ]
      }
    }
  },
  "selfLink": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/us-central1-a/instanceGroupManagers/a3-dws/resizeRequests/tf-test-a3-dwsgbbsro3e6z",
  "selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/us-central1-a/instanceGroupManagers/a3-dws/resizeRequests/9113303207974357537"
}

It looks like the error.errors field is currently defined as a single nested object instead of a list of objects.

SarahFrench commented 1 month ago

Note: the person addressing this issue might also address https://github.com/hashicorp/terraform-provider-google/issues/19918 at the same time.

melinath commented 2 weeks ago

This is now failing with the error:

        Error: Error creating RegionInstanceTemplate: googleapi: Error 409: The resource 'projects/ci-test-project-nightly-ga/regions/us-central1/instanceTemplates/a3-dws' already exists, alreadyExists

In addition to fixing the panic, the test needs to use variables properly to get a tf-test prefix and random suffix used in all resource names as described on https://googlecloudplatform.github.io/magic-modules/develop/test/test/