From e3a05455872268436c35ce7e7b1cdc3b0b7bf432 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Wed, 29 Jul 2026 13:44:54 -0500 Subject: [PATCH] container: fix ignore_node_count_changes flattener permadiff in google_container_cluster Fixes https://github.com/hashicorp/terraform-provider-google/issues/27946 This PR fixes a plan-time permadiff where ignore_node_count_changes was not persisted in the inline node_pool blocks of google_container_cluster in flattenNodePool. Also adds node_pool.0.managed_instance_group_urls to ImportStateVerifyIgnore in TestAccContainerCluster_regionalWithNodePool with an adjacent comment explaining why it is required on import. ```release-note:bug container: fixed a plan-time permadiff where `ignore_node_count_changes` was not persisted in the inline `node_pool` blocks of `google_container_cluster` ``` --- .../resource_container_cluster_internal_test.go.tmpl | 6 ++++++ .../container/resource_container_cluster_test.go.tmpl | 4 +++- .../services/container/resource_container_node_pool.go.tmpl | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster_internal_test.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_cluster_internal_test.go.tmpl index fd84d987f04c..e48e516d2545 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster_internal_test.go.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster_internal_test.go.tmpl @@ -664,6 +664,10 @@ func TestUnitFlattenClusterNodePools(t *testing.T) { Optional: true, Elem: &schema.Resource{Schema: map[string]*schema.Schema{"create_pod_range": {Type: schema.TypeBool}}}, }, + "ignore_node_count_changes": { + Type: schema.TypeBool, + Optional: true, + }, }, }, Optional: true, @@ -701,6 +705,7 @@ func TestUnitFlattenClusterNodePools(t *testing.T) { "managed_instance_group_urls": []string{}, "version": "", "network_config": []map[string]interface{}{}, + "ignore_node_count_changes": false, }, { "name": "pool-2", @@ -713,6 +718,7 @@ func TestUnitFlattenClusterNodePools(t *testing.T) { "managed_instance_group_urls": []string{}, "version": "", "network_config": []map[string]interface{}{}, + "ignore_node_count_changes": false, }, }, expectError: false, diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl index da21832b9613..dbb85f65208b 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl @@ -1992,7 +1992,9 @@ func TestAccContainerCluster_regionalWithNodePool(t *testing.T) { ResourceName: "google_container_cluster.regional", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"deletion_protection", "ignore_node_count_changes", "node_pool.0.ignore_node_count_changes"}, + // Virtual fields like ignore_node_count_changes are not loaded on import. When import runs with default + // false for ignore_node_count_changes, managed_instance_group_urls is populated from the API, causing an import diff. + ImportStateVerifyIgnore: []string{"deletion_protection", "ignore_node_count_changes", "node_pool.0.ignore_node_count_changes", "node_pool.0.managed_instance_group_urls"}, }, }, }) diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl index e808ce486cb7..4e7b40d61257 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl +++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl @@ -1562,7 +1562,8 @@ func flattenNodePool(d *schema.ResourceData, config *transport_tpg.Config, np *c "instance_group_urls": igmUrls, "managed_instance_group_urls": managedIgmUrls, "version": np.Version, - "network_config": flattenNodeNetworkConfig(np.NetworkConfig, d, prefix), + "network_config": flattenNodeNetworkConfig(np.NetworkConfig, d, prefix), + "ignore_node_count_changes": d.Get(prefix + "ignore_node_count_changes"), } if np.Autoscaling != nil {