{"record":{"id":"b140db9dc7fd7711","repo":"kubernetes/kops","slug":"error-fetching-gce-instance-group-template-q-v","errorCode":null,"errorMessage":"error fetching GCE instance group template %q: %v","messagePattern":"error fetching GCE instance group template %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodeidentity/gce/identify.go","lineNumber":227,"sourceCode":"\tinfo.Labels = labels\n\treturn info, nil\n}\n\n// getInstance queries GCE for the instance with the specified name, returning an error if not found\nfunc (i *nodeIdentifier) getInstance(zone string, instanceName string) (*compute.Instance, error) {\n\tinstance, err := i.computeService.Instances.Get(i.project, zone, instanceName).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error fetching GCE instance: %w\", err)\n\t}\n\n\treturn instance, nil\n}\n\n// getInstanceTemplate queries GCE for the IG Template with the specified name, returning an error if not found\nfunc (i *nodeIdentifier) getInstanceTemplate(name string) (*compute.InstanceTemplate, error) {\n\tt, err := i.computeService.InstanceTemplates.Get(i.project, name).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error fetching GCE instance group template %q: %v\", name, err)\n\t}\n\n\treturn t, nil\n}\n\n// getMIG queries GCE for the MIG with the specified name, returning an error if not found\nfunc (i *nodeIdentifier) getMIG(zone string, migName string) (*compute.InstanceGroupManager, error) {\n\tmig, err := i.computeService.InstanceGroupManagers.Get(i.project, zone, migName).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error fetching GCE managed instance group %q: %v\", migName, err)\n\t}\n\n\treturn mig, nil\n}\n\n// getManagedInstance queries GCE for the instance from the MIG\nfunc (i *nodeIdentifier) getManagedInstance(ctx context.Context, mig *compute.InstanceGroupManager, instanceID uint64) (*compute.ManagedInstance, error) {\n\tvar matches []*compute.ManagedInstance","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodeidentity/gce/identify.go#L209-L245","documentation":"kops' GCE node identity lookup could not retrieve the named instance template from the Google Compute Engine API while resolving which template a node's managed instance group uses. It wraps the raw googleapi error with the template name for context. The InstanceTemplates.Get call can fail due to API errors, permissions, or the template no longer existing.","triggerScenarios":"i.computeService.InstanceTemplates.Get(project, name).Do() returns an error: template deleted, wrong project, permission denied (compute.instanceTemplates.get), quota/rate-limit, or transient API outage.","commonSituations":"Instance template renamed or recreated by a kops update while an old node still reports to the cluster; GCE API credentials lacking compute viewer role; typos/mismatch of project after cluster migration.","solutions":["Verify the instance template still exists: gcloud compute instance-templates describe <name> --project <project>","Check the service account has compute.instanceTemplates.get permission (roles/compute.viewer)","Re-run kops update/rolling-update so MIGs reference current templates","If the error is transient (5xx/rate limit), retry after backoff"],"exampleFix":"// before: error surfaces with wrapped message only\n// after: log template name and project for faster diagnosis\nif err != nil {\n  return nil, fmt.Errorf(\"error fetching GCE instance group template %q in project %s: %w\", name, i.project, err)\n}","handlingStrategy":"retry","validationCode":"if _, err := gcloudLikeCheck(name); err != nil { /* skip or recreate template */ }","typeGuard":"func templateFound(t *compute.InstanceTemplate, err error) bool { return err == nil && t != nil }","tryCatchPattern":"t, err := getInstanceTemplate(name)\nif err != nil {\n  if isNotFound(err) { /* recreate template via kops update */ }\n  else if isTransient(err) { /* backoff retry */ }\n  return err\n}","preventionTips":["Keep instance templates aligned with `kops update cluster` before rolling nodes","Grant the controller service account roles/compute.viewer","Set retry/backoff on GCE API clients for 429/5xx"],"tags":["gce","node-identity","api-error","kops-controller"],"backgroundTag":"gcp-api-fetch-failed","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"}