Skip to content

fix: GKE cluster update behavior#1518

Merged
matttrach merged 1 commit into
rancher:masterfrom
krunalhinguu:fix-gke-update-issue
May 30, 2025
Merged

fix: GKE cluster update behavior#1518
matttrach merged 1 commit into
rancher:masterfrom
krunalhinguu:fix-gke-update-issue

Conversation

@krunalhinguu
Copy link
Copy Markdown
Contributor

@krunalhinguu krunalhinguu commented May 29, 2025

Issue

#1499 This PR resolves an issue where any change to a GKE cluster's node_pool in Terraform caused a full cluster replacement, which was disruptive and not necessary in most cases.


Problem

In the existing implementation of the rancher2_cluster resource for GKE clusters, the node_pool block was marked with ForceNew, which forced a full replacement of the cluster whenever any node pool change was made. This made it impossible to perform in-place updates like scaling or updating node pool properties without recreating the entire cluster.


Solution

  • Removed ForceNew from the node_pool field in the Terraform schema.
  • Added custom diff logic in the update function to properly detect and apply in-place changes to node_pool entries.

These changes allow users to modify existing GKE node pools without triggering full cluster recreation, improving usability and minimizing downtime.


Testing

Manual Testing

  • Created a GKE cluster via Rancher using Terraform.
  • Modified node pool fields (e.g., machine type, labels, node count).
  • Verified that Terraform plan shows in-place updates, and apply works without cluster replacement.
  • Confirmed updated configuration reflected correctly in Rancher UI and GCP Console.

Automated Testing

  • No new automated tests added for this change.
  • Existing tests for rancher2_cluster still pass, confirming backward compatibility.

QA Testing Considerations

  • Test updating an existing GKE cluster's node pool (e.g., changing node count, version, labels).
  • Confirm no full cluster replacement occurs.
  • Validate that updates are reflected correctly in Rancher and on GKE.
  • Test both new cluster creation and update flows to confirm schema compatibility.

Regressions Considerations

  • Changes to node_pool update behavior could potentially cause issues if Rancher expects fields that are no longer being sent.
  • Regressions are low to medium risk, but QA should test edge cases like:
    • Reducing node count to 0
    • Removing a node pool
    • Updating multiple properties at once

@krunalhinguu krunalhinguu force-pushed the fix-gke-update-issue branch from ddc7edd to 352d2c2 Compare May 29, 2025 03:26
@krunalhinguu krunalhinguu changed the title Improve GKE cluster update behavior fix: GKE cluster update behavior May 29, 2025
@matttrach matttrach added kind/enhancement release/v8 Release with v8.x correlating to Rancher's v2.12.x labels May 29, 2025
@matttrach
Copy link
Copy Markdown
Collaborator

This change is currently targeting Rancher v2.12.0 which coincides with v8.0.0 of this project. Please let me know if you need this to be backported to other versions.

@matttrach matttrach added this to the July Release milestone May 29, 2025
@krunalhinguu krunalhinguu requested a review from mjura May 29, 2025 16:10
Copy link
Copy Markdown
Contributor

@mjura mjura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matttrach
Copy link
Copy Markdown
Collaborator

Please sign your commits with a valid key so that we can merge.

@matttrach matttrach self-assigned this May 30, 2025
@krunalhinguu krunalhinguu force-pushed the fix-gke-update-issue branch from 352d2c2 to b4698af Compare May 30, 2025 15:41
@matttrach matttrach merged commit 56a7b45 into rancher:master May 30, 2025
1 check passed
krunalhinguu added a commit to krunalhinguu/terraform-provider-rancher2 that referenced this pull request Jun 3, 2025
krunalhinguu added a commit to krunalhinguu/terraform-provider-rancher2 that referenced this pull request Jun 3, 2025
krunalhinguu added a commit to krunalhinguu/terraform-provider-rancher2 that referenced this pull request Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/v8 Release with v8.x correlating to Rancher's v2.12.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants