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.29k stars 1.72k forks source link

Removing All Labels on GKE Node Pool Fails #15848

Open drcapulet opened 1 year ago

drcapulet commented 1 year ago

Community Note

Terraform Version

$ terraform -v
Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.82.0
+ provider registry.terraform.io/hashicorp/random v3.5.1

Affected Resource(s)

Terraform Configuration Files

resource "google_service_account" "default" {
  account_id   = "service-account-id"
  display_name = "Service Account"
}

resource "google_container_cluster" "primary" {
  name     = "primary"
  location = "us-central1"

  remove_default_node_pool = true
  initial_node_count       = 1
}

resource "google_container_node_pool" "main" {
  name       = "main"
  cluster    = google_container_cluster.primary.id
  node_count = 1

  node_config {
    preemptible  = true
    machine_type = "e2-medium"

    labels = {
      example = "label"
    }

    service_account = google_service_account.default.email
    oauth_scopes = [
      "https://www.googleapis.com/auth/cloud-platform"
    ]
  }
}

Debug Output

2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: ---[ REQUEST ]---------------------------------------
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: PUT /v1/projects/example-project/locations/us-central1/clusters/primary/nodePools/main?alt=json&prettyPrint=false HTTP/1.1
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Host: container.googleapis.com
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: User-Agent: google-api-go-client/0.5 Terraform/1.5.7 (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google/4.82.0
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Content-Length: 19
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Content-Type: application/json
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: X-Goog-Api-Client: gl-go/1.19.9 gdcl/0.138.0
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Accept-Encoding: gzip
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: {
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:  "name": "main"
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: }
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:
2023-09-14T13:47:00.021-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: -----------------------------------------------------
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: 2023/09/14 13:47:00 [DEBUG] Google API Response Details:
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: ---[ RESPONSE ]--------------------------------------
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: HTTP/2.0 400 Bad Request
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Cache-Control: private
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Content-Type: application/json; charset=UTF-8
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Date: Thu, 14 Sep 2023 18:47:00 GMT
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Server: ESF
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Vary: Origin
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Vary: X-Origin
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: Vary: Referer
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: X-Content-Type-Options: nosniff
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: X-Frame-Options: SAMEORIGIN
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: X-Xss-Protection: 0
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: {
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:   "error": {
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     "code": 400,
2023-09-14T13:47:00.381-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     "message": "At least one of ['node_version', 'image_type', 'updated_node_pool', 'locations', 'workload_metadata_config', 'upgrade_settings', 'kubelet_config', 'linux_node_config', 'tags', 'taints', 'labels', 'node_network_config', 'gcfs_config', 'gvnic', 'confidential_nodes', 'logging_config', 'fast_socket', 'resource_labels', 'accelerators', 'windows_node_config', 'machine_type', 'disk_type', 'disk_size_gb', 'containerd_config', 'resource_manager_tags'] must be specified.",
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     "errors": [
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:       {
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:         "message": "At least one of ['node_version', 'image_type', 'updated_node_pool', 'locations', 'workload_metadata_config', 'upgrade_settings', 'kubelet_config', 'linux_node_config', 'tags', 'taints', 'labels', 'node_network_config', 'gcfs_config', 'gvnic', 'confidential_nodes', 'logging_config', 'fast_socket', 'resource_labels', 'accelerators', 'windows_node_config', 'machine_type', 'disk_type', 'disk_size_gb', 'containerd_config', 'resource_manager_tags'] must be specified.",
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:         "domain": "global",
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:         "reason": "badRequest"
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:       }
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     ],
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     "status": "INVALID_ARGUMENT",
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     "details": [
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:       {
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:         "@type": "type.googleapis.com/google.rpc.RequestInfo",
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:         "requestId": "0x3847051cd04685a"
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:       }
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:     ]
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5:   }
2023-09-14T13:47:00.382-0500 [DEBUG] provider.terraform-provider-google_v4.82.0_x5: }

Expected Behavior

Labels on the node pool are removed.

Actual Behavior

│ Error: googleapi: Error 400: At least one of ['node_version', 'image_type', 'updated_node_pool', 'locations', 'workload_metadata_config', 'upgrade_settings', 'kubelet_config', 'linux_node_config', 'tags', 'taints', 'labels', 'node_network_config', 'gcfs_config', 'gvnic', 'confidential_nodes', 'logging_config', 'fast_socket', 'resource_labels', 'accelerators', 'windows_node_config', 'machine_type', 'disk_type', 'disk_size_gb', 'containerd_config', 'resource_manager_tags'] must be specified.

Steps to Reproduce

  1. Remove node_config.labels or set to {}
  2. terraform apply

b/300616676

880831ian commented 8 months ago

Hello, I want to ask, is there any solution at present?

trenslow commented 1 month ago

this is still an issue on provider registry.terraform.io/hashicorp/google v5.27.0