{"record":{"id":"bfea56d82ece4ed6","repo":"kubernetes/kops","slug":"unable-to-determine-gcp-region-for-cluster","errorCode":null,"errorMessage":"unable to determine gcp region for cluster","messagePattern":"unable to determine gcp region for cluster","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/controllers/clusterapi/cluster_controller.go","lineNumber":128,"sourceCode":"func (s *clusterScope) applyGCPCluster(ctx context.Context, kube client.Client) error {\n\t// This is because of network tags in cloud-provider-gcp\n\t// TODO: cloud-provider-gcp should not assume cluster name is a valid prefix\n\tname := gce.SafeClusterName(s.Cluster.GetName())\n\n\tgcpProject := s.Cluster.Spec.Project\n\tif gcpProject == \"\" {\n\t\treturn fmt.Errorf(\"unable to determine gcp project for cluster\")\n\t}\n\tgcpRegion := \"\"\n\tfor _, subnet := range s.Cluster.Spec.Subnets {\n\t\tif gcpRegion == \"\" {\n\t\t\tgcpRegion = subnet.Region\n\t\t} else if gcpRegion != subnet.Region {\n\t\t\treturn fmt.Errorf(\"found multiple gcp regions for cluster\")\n\t\t}\n\t}\n\tif gcpRegion == \"\" {\n\t\treturn fmt.Errorf(\"unable to determine gcp region for cluster\")\n\t}\n\n\t// TODO: Sync with LinkToNetwork\n\tgcpNetworkName := s.Cluster.Spec.NetworkID\n\tif gcpNetworkName == \"\" {\n\t\tgcpNetworkName = gce.SafeTruncatedClusterName(s.Cluster.ObjectMeta.Name, 63)\n\t}\n\tif gcpNetworkName == \"\" {\n\t\treturn fmt.Errorf(\"unable to determine gcp network for cluster\")\n\t}\n\n\tobj := map[string]any{\n\t\t\"apiVersion\": \"infrastructure.cluster.x-k8s.io/v1beta1\",\n\t\t\"kind\":       \"GCPCluster\",\n\t\t\"metadata\": map[string]any{\n\t\t\t\"name\":      name,\n\t\t\t\"namespace\": s.namespace(),\n\t\t},","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/controllers/clusterapi/cluster_controller.go#L110-L146","documentation":"applyGCPCluster could not derive a region for the GCPCluster object: after iterating the cluster's subnets, no usable region was found (subnet regions empty or the loop produced nothing) — the sibling checks for missing project and conflicting multiple regions are separate errors.","triggerScenarios":"clusterScope.Apply() on a GCP cluster where the subnets loop ends with gcpRegion still empty (no subnets, or none with region populated).","commonSituations":"Cluster manifests generated without subnet region fields; subnets defined with only names/CIDRs; utility or topology subnets (e.g. only a bastion subnet) left without region.","solutions":["Set region on every subnet in spec.subnets","Ensure at least one subnet exists in the cluster spec","Re-run reconciliation after applying the corrected manifest"],"exampleFix":"// before\nsubnets:\n- name: us-west1\n  type: Private\n// after\nsubnets:\n- name: us-west1\n  type: Private\n  region: us-west1","handlingStrategy":"validation","validationCode":"if len(cluster.Spec.Subnets) == 0 {\n\treturn fmt.Errorf(\"cluster %s: at least one subnet with region required\", cluster.Name)\n}\nfor _, s := range cluster.Spec.Subnets {\n\tif s.Region == \"\" { return fmt.Errorf(\"subnet %s missing region\", s.Name) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set region on every subnet definition","Require at least one non-topology subnet per GCP cluster","Lint cluster manifests for required subnet fields"],"tags":["gcp","clusterapi","region"],"backgroundTag":"missing-gcp-region","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}