{"record":{"id":"3145f8c4fa18c281","repo":"kubernetes/kops","slug":"unable-to-determine-zones-in-region-q","errorCode":null,"errorMessage":"unable to determine zones in region %q","messagePattern":"unable to determine zones in region %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/gce/gce.go","lineNumber":93,"sourceCode":"\n\t{\n\t\t// TODO: Only zones in api.Cluster object, if we have one?\n\t\tgceZones, err := d.gceCloud.Compute().Zones().List(ctx, d.gceCloud.Project())\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error listing zones: %v\", err)\n\t\t}\n\t\tfor _, gceZone := range gceZones {\n\t\t\tu, err := gce.ParseGoogleCloudURL(gceZone.Region)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif u.Name != region {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\td.zones = append(d.zones, gceZone.Name)\n\t\t}\n\t\tif len(d.zones) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"unable to determine zones in region %q\", region)\n\t\t}\n\t\tklog.Infof(\"Scanning zones: %v\", d.zones)\n\t}\n\n\tlistFunctions := []gceListFn{\n\t\td.listGCEInstanceTemplates,\n\t\td.listInstanceGroupManagersAndInstances,\n\t\td.listTargetPools,\n\t\td.listForwardingRules,\n\t\td.listFirewallRules,\n\t\td.listGCEDisks,\n\t\td.listAddresses,\n\t\td.listSubnets,\n\t\td.listRouters,\n\t\td.listNetworks,\n\t\td.listServiceAccounts,\n\t\td.listBackendServices,\n\t\td.listHealthchecks,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/gce/gce.go#L75-L111","documentation":"After listing zones, ListResourcesGCE filters zones whose region matches the cluster's region and collects their names into d.zones; if no zone matched, it fails with 'unable to determine zones in region %q'. This indicates the region configured for the cluster has no listed zones, i.e. the region name is wrong or the project can't see that region.","triggerScenarios":"The resolved region string doesn't match any gceZone.Region returned by the API — typically a misspelled region (e.g. 'us-east1' vs 'us-east1-b' or 'us-central'), a region not available to the project, or ParseGoogleCloudURL producing an unexpected u.Name.","commonSituations":"Typo in the cluster spec's region, running against a project where the chosen region is disabled/not yet available, or GCP added/removed zones leaving an edge case where region exists but filtering logic mismatches.","solutions":["Verify the region with 'gcloud compute zones list --project <project>' and make sure the cluster's region exactly matches (e.g. 'us-east1', not a zone like 'us-east1-b').","Correct the region in the kops cluster spec and re-run the command.","If the region is valid but zones are missing, check GCP region availability for the project or contact GCP support.","Add debug logging (klog) of each gceZone.Region vs the target region to spot normalization mismatches."],"exampleFix":"// before\nif len(d.zones) == 0 {\n\treturn nil, fmt.Errorf(\"unable to determine zones in region %q\", region)\n}\n// after\nif len(d.zones) == 0 {\n\treturn nil, fmt.Errorf(\"unable to determine zones in region %q (project %q)\", region, d.gceCloud.Project())\n}","handlingStrategy":"validation","validationCode":"// validate region against the live project before listing resources\nzones, err := computeService.Zones.List(project).Do()\nif err != nil { return err }\nvalid := map[string]bool{}\nfor _, z := range zones.Items {\n\tregion := z.Region[strings.LastIndex(z.Region, \"/\")+1:]\n\tvalid[region] = true\n}\nif !valid[targetRegion] {\n\treturn fmt.Errorf(\"region %q has no zones in project %q; valid: %v\", targetRegion, project, valid)\n}","typeGuard":"var gceRegionRe = regexp.MustCompile(`^[a-z]+-[a-z]+[0-9]$`)\nfunc isWellFormedGCPRegion(r string) bool { return gceRegionRe.MatchString(r) }","tryCatchPattern":"if err := ListResourcesGCE(ctx, d, cluster, op); err != nil {\n\tif strings.Contains(err.Error(), \"unable to determine zones in region\") {\n\t\t// surface valid regions to the user instead of a bare failure\n\t\treturn fmt.Errorf(\"%v — check the cluster spec's region (must be like 'us-east1', not a zone name)\", err)\n\t}\n\treturn err\n}","preventionTips":["Verify region names with 'gcloud compute zones list' before configuring the cluster","Never put a zone name (us-east1-b) where a region (us-east1) is expected","Confirm the region is available in your GCP project/organization policies","Log zone.Region values during listing to catch normalization mismatches"],"tags":["gce","gcp","configuration","regions"],"backgroundTag":"no-zones-found-in-region","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}