Repository navigation
Conversation
… Day-2 drift Sort monitoring_config.enable_components into GKE's canonical MonitoringComponentConfig.Component enum order (SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, CADVISOR, KUBELET, DCGM, JOBSET) while preserving any unrecognized future component strings at the end, and guard DCGM injection on non-empty var.monitoring_components.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a recurring Day-2 drift issue in GKE cluster configurations caused by mismatched ordering of monitoring components between Terraform and the GKE API. By enforcing the canonical enum order used by the GKE control plane, the changes ensure that Terraform plans remain stable and avoid unnecessary cluster updates that previously locked resources and caused secondary side effects during deployment. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request standardizes the ordering of GKE monitoring components in the GKE cluster module. It introduces a local ordered list gke_monitoring_component_order and logic to sort the enabled monitoring components accordingly, preventing potential configuration drift due to list ordering. The default values in variables.tf and the documentation in README.md have been updated to reflect this new order. I have no additional feedback to provide as the implementation is clean and follows best practices.
Summary
Canonicalizes the ordering of
monitoring_config.enable_componentsinmodules/scheduler/gke-clusterto match the GKE control plane's canonicalMonitoringComponentConfig.Componentprotobuf enum order:var.monitoring_componentslist inmodules/scheduler/gke-cluster/variables.tfso"STORAGE"and"HPA"appear immediately after"SYSTEM_COMPONENTS".local.monitoring_componentsinmodules/scheduler/gke-cluster/main.tfagainst GKE's canonical enum order (SYSTEM_COMPONENTS,APISERVER,SCHEDULER,CONTROLLER_MANAGER,STORAGE,HPA,POD,DAEMONSET,DEPLOYMENT,STATEFULSET,CADVISOR,KUBELET,DCGM,JOBSET) while preserving any unrecognized future component strings at the end."DCGM"injection withlength(var.monitoring_components) > 0so settingmonitoring_components = []cleanly disables GKE monitoring even whenenable_dcgm_monitoringis left at its defaulttrue.Root Cause & Impact
In
terraform-provider-google/google-beta7.x,google_container_cluster.monitoring_config.enable_componentshas schemaType: schema.TypeList. On cluster reads, the GKE API always returnsmonitoringConfig.componentConfig.enableComponentssorted in GKE's canonical protobuf enum order. Becausevariables.tfpreviously placed"STORAGE"and"HPA"after"STATEFULSET"andmain.tfappended"DCGM"after"JOBSET", every Day-2gcluster deploy/terraform planagainst an existing GKE cluster detected a spurious in-place update ongoogle_container_cluster.gke_cluster:UpdateClusterInternalcontrol-plane operation that locked the cluster and blocked concurrent node-pool mutations.module.workload_identitydata sources (depends_on = [google_container_cluster.gke_cluster]) to defer evaluation to apply time, recreatinggoogle_service_account_iam_member.mainon every Day-2 run.Compatibility
.tfstate, so Day-2terraform planbecomes a 0-diff no-op.terraform-provider-google>= 8.0.0: Compatible with both7.x(schema.TypeList) and>= 8.0.0(schema.TypeSet).