{"record":{"id":"e3410c938d14ee96","repo":"kubernetes/kops","slug":"unable-to-determine-gcp-project-for-cluster","errorCode":null,"errorMessage":"unable to determine gcp project for cluster","messagePattern":"unable to determine gcp project for cluster","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/controllers/clusterapi/cluster_controller.go","lineNumber":117,"sourceCode":"\t\treturn err\n\t}\n\tif err := s.createKopsControlPlane(ctx, kube); err != nil {\n\t\treturn err\n\t}\n\tif err := s.createClusterObject(ctx, kube); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc (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}","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/controllers/clusterapi/cluster_controller.go#L99-L135","documentation":"applyGCPCluster requires Cluster.Spec.Project to be set because the GCPCluster CAPI object must reference a GCP project. When the project field is empty, it returns this error instead of guessing. It means the kops Cluster spec lacks the mandatory GCP project.","triggerScenarios":"clusterScope.Apply() on a GCP cluster whose Cluster.Spec.Project is empty, during CAPI controller reconciliation.","commonSituations":"Cluster created without 'kops create cluster --project' or with spec.project deleted; migration of cluster manifest between clouds; automation generating manifests that omit project.","solutions":["Set spec.project in the kops Cluster spec to the target GCP project ID","Recreate the cluster with --project <gcp-project-id> if initially omitted","Re-run reconciliation after applying the corrected spec"],"exampleFix":"// before\nspec:\n  subnets: [...]   # project missing\n// after\nspec:\n  project: my-gcp-project\n  subnets: [...]","handlingStrategy":"validation","validationCode":"if len(cluster.Spec.Subnets) > 0 && cluster.Spec.Project == \"\" {\n\treturn fmt.Errorf(\"cluster %s: spec.project required for GCP\", cluster.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --project when creating GCP clusters","Add spec validation in admission/webhook for GCP clusters missing project","Review manifests after migration between clouds"],"tags":["gcp","clusterapi","config-missing"],"backgroundTag":"missing-gcp-project","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"}