Skip to content

container: add skip_node_pool_refresh to google_container_cluster data source - #18880

Open
ralbertazzi wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
ralbertazzi:datasource-skip-node-pool-refresh
Open

container: add skip_node_pool_refresh to google_container_cluster data source#18880
ralbertazzi wants to merge 2 commits into
GoogleCloudPlatform:mainfrom
ralbertazzi:datasource-skip-node-pool-refresh

Conversation

@ralbertazzi

Copy link
Copy Markdown

Fixes hashicorp/terraform-provider-google#29171

Description

The skip_node_pool_refresh performance flag added to the google_container_cluster resource in #17968 is not usable from the corresponding data source: DatasourceSchemaFromResourceSchema copies every resource field as computed-only, so the flag exists on the data source but cannot be set.

The data source read path already honors the flag — datasourceContainerClusterRead delegates to resourceContainerClusterRead, which skips the node pool flattening in flattenClusterNodePools when the flag is set. This PR makes the field settable via AddOptionalFieldsToSchema, so users with clusters that have a high node pool count can opt out of the node pool read:

data "google_container_cluster" "my_cluster" {
  name     = "my-cluster"
  location = "us-east1-a"

  skip_node_pool_refresh = true
}

When enabled, the data source's node_pool attribute remains empty ([]), matching the resource-side behavior.

Testing

  • Generated the google provider locally and confirmed the diff is scoped to the data source, its test, and the data source docs
  • Provider builds and go vet/go test ./google/services/container/ pass (including TestUnitFlattenClusterNodePools)
  • A local check confirmed the generated data source schema marks skip_node_pool_refresh as Optional while node_pool stays computed-only
  • Added TestAccContainerClusterDatasource_skipNodePoolRefresh, mirroring the existing data source tests, which asserts node_pool.# = 0 when the flag is set (requires a real GCP project / VCR cassette to run)

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

container: added `skip_node_pool_refresh` field to `google_container_cluster` data source. When set to true, the data source skips reading node pools from the API, resolving long read times on clusters with a large number of node pools. Note that this results in `node_pool` being set to an empty list

🤖 Generated with OpenCode (GPT-5.6 Terra)

…a source

Expose the existing resource-side performance flag on the corresponding data
source. The data source read path already honors the flag via
flattenClusterNodePools; this makes the field settable instead of
computed-only, so users can opt out of the node pool read on clusters with a
high node pool count.

Fixes hashicorp/terraform-provider-google#29171

🤖 Generated with [OpenCode](https://opencode.ai) (GPT-5.6 Terra)
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 3, 2026
@google-cla

google-cla Bot commented Sep 3, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions
github-actions Bot requested a review from melinath September 3, 2026 07:39
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

🤖 Generated with [OpenCode](https://opencode.ai) (GPT-5.6 Luna)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance: add skip_node_pool_refresh option to google_container_cluster data source

2 participants