Skip to content

Fix GKE ignore_node_count_changes flag and stale IGM cache#18397

Open
c2thorn wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
c2thorn:fix-gke-ignore-node-count-changes
Open

Fix GKE ignore_node_count_changes flag and stale IGM cache#18397
c2thorn wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
c2thorn:fix-gke-ignore-node-count-changes

Conversation

@c2thorn

@c2thorn c2thorn commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes hashicorp/terraform-provider-google#27946
Fixes hashicorp/terraform-provider-google#27966

This PR fixes 3 bugs or test failures introduced by PR #17968 for the GKE ignore_node_count_changes flag. PR #17968 successfully reduced reduced plan-time API calls by via the new flag, but was rushed as a high priority issue and missed a few things.


1: Flattener Bug

PR #17968 failed to persist the flag's state in google_container_cluster.node_pool.ignore_node_count_changes despite working correctly in google_container_node_pool.ignore_node_count_changes.

To address this, this PR adds the missing ignore_node_count_changes field mapping to google_container_cluster's flattenNodePool.


2: Test Failure TestAccContainerCluster_regionalWithNodePool

PR #17968 added the new flag to TestAccContainerCluster_regionalWithNodePool. The test was dismissed as flaky in VCR since it failed with

        Error: Error waiting for creating GKE cluster: Try a different location, or try again later: Google Compute Engine does not have enough resources available to fulfill request: us-central1.

However it actually failed in non-VCR runs with

              ~ node_pool {
                  ~ ignore_node_count_changes   = false -> true

The flattenNodePool fix from Bug #1 resolves this immediate diff, but exposes a new diff on the import step. Virtual fields are not loaded on import and are usually fixed by ImportStateVerifyIgnore. This doesn't work for ignore_node_count_changes because if the acceptance test config sets ignore_node_count_changes to true, but the import step sets it to the default false, the node counts are not ignored and managed_instance_group_urls is populated, resulting in a new import diff for managed_instance_group_urls.

This means for import steps where ignore_node_count_changes is true, both ignore_node_count_changes and managed_instance_group_urls should be ignored on the import step.


3: Test Failure TestAccContainerNodePool_ignoreNodeCountChanges

TestAccContainerNodePool_ignoreNodeCountChanges fails outside of VCR tests because of caching. Stale GCE instance group manager counts were served from the provider cache after config updates, causing

    resource_container_node_pool_test.go:7010: Step 3/4 error: Check failed: Check 1/2 error: Check 1/1 error: google_container_node_pool.np: Attribute 'node_count' expected "3", got "2"

To fix this, this PR invalidates the IGM cache during count resizing or anytime ignore_node_count_changes is active, in order to make sure stale node counts do not persist after they are ignored by the flag. The cache is a provider-only client-side cache, and it makes sense to empty in these scenarios because once counts have been updated or ignored, the cached values are no longer guaranteed to reflect actual API values.


Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

container: fixed a plan-time permadiff where `ignore_node_count_changes` was not persisted in the inline `node_pool` blocks of `google_container_cluster`
container: fixed a bug where `google_container_node_pool` and `google_container_cluster` failed to invalidate their Instance Group Manager cache when a resize occurred or when `ignore_node_count_changes` was active

@c2thorn c2thorn changed the title Fix GKE ignore_node_count_changes flags and stale IGM cache Fix GKE ignore_node_count_changes flag and stale IGM cache Jul 24, 2026
@modular-magician

modular-magician commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 08fb586:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
google provider View Diff 3 files changed, 24 insertions(+), 1 deletion(-)
google-beta provider View Diff 3 files changed, 24 insertions(+), 1 deletion(-)

Test report

Analytics

Total Tests Passed Skipped Affected
320 305 14 1
Affected Service Packages
  • container

Learn how VCR tests work


Step 1: Replaying Mode

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit.

Click here to see the affected tests
  • TestAccContainerNodePool_withHostMaintenancePolicy

View the replaying VCR build log


Step 2: Recording Mode

Recording Mode Replaying Rerun Test Name
❌ Error · Log - TestAccContainerNodePool_withHostMaintenancePolicy

Caution

Issues requiring attention before PR completion

🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details.

Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer.

View the recording VCR build log or the debug logs folder for detailed results.

@c2thorn VCR tests complete for 08fb586!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing test(s): TestAccContainerNodePool_ignoreNodeCountChanges Failing test(s): TestAccContainerCluster_regionalWithNodePool

2 participants