{"record":{"id":"f9a9399c6552cae6","repo":"kubernetes/kops","slug":"error-listing-instancetemplates-v","errorCode":null,"errorMessage":"error listing InstanceTemplates: %v","messagePattern":"error listing InstanceTemplates: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instancetemplate.go","lineNumber":105,"sourceCode":"\nvar (\n\t_ fi.CloudupTask   = &InstanceTemplate{}\n\t_ fi.CompareWithID = &InstanceTemplate{}\n)\n\nfunc (e *InstanceTemplate) CompareWithID() *string {\n\treturn e.ID\n}\n\nfunc (e *InstanceTemplate) Find(c *fi.CloudupContext) (*InstanceTemplate, error) {\n\tcloud := c.T.Cloud.(gce.GCECloud)\n\n\ttemplates, err := cloud.Compute().InstanceTemplates().List(context.Background(), cloud.Project())\n\tif err != nil {\n\t\tif gce.IsNotFound(err) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error listing InstanceTemplates: %v\", err)\n\t}\n\n\texpected, err := e.mapToGCE(cloud.Project(), cloud.Region())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, r := range templates {\n\t\tif !strings.HasPrefix(r.Name, fi.ValueOf(e.NamePrefix)+\"-\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !matches(expected, r) {\n\t\t\tcontinue\n\t\t}\n\n\t\tactual := &InstanceTemplate{}\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go#L87-L123","documentation":"The InstanceTemplate Find task lists all instance templates in the GCE project via the Compute API to locate the template matching this task's NamePrefix. If the List call fails with anything other than a NotFound, the task wraps and returns the underlying API error with this message.","triggerScenarios":"The compute.googleapis.com InstanceTemplates.List call returns a non-404 error: expired/insufficient service-account credentials, the Compute API disabled in the project, quota/rate-limit (429), transient 5xx from GCP, or network failure from the kOps node.","commonSituations":"Service account keys rotated/revoked mid-run; compute API not enabled on a new project; GCP regional outage or rate limiting during a large `kops update cluster`; wrong project configured so the caller lacks compute.reader.","solutions":["Read the wrapped inner error to identify the HTTP status/code","Verify the Compute Engine API is enabled: `gcloud services list --enabled` in the target project","Check credentials: ensure the service account has compute.admin/compute.viewer and the key is valid (`gcloud auth activate-service-account` test)","If rate-limited (429), retry after backoff or reduce concurrent API usage","If transient 5xx, simply re-run `kops update cluster`"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before running kops, sanity-check API access:\n//   gcloud compute instance-templates list --project <project> > /dev/null\n//   gcloud services list --enabled --project <project> | grep compute.googleapis.com","typeGuard":null,"tryCatchPattern":"err := kops.UpdateCluster(...)\nif err != nil && strings.Contains(err.Error(), \"error listing InstanceTemplates\") {\n    // inspect wrapped cause; retry on 429/5xx, fail fast on 401/403\n    if isTransient(err) { backoffAndRetry() }\n}","preventionTips":["Verify the Compute Engine API is enabled on the target project before cluster operations","Grant the kOps service account compute.admin (or at least compute.viewer) and rotate keys before expiry","Avoid running large concurrent kOps operations that could hit Compute API rate limits","Check status.cloud.google.com for Compute API incidents before scheduled cluster updates"],"tags":["gce","api-error","instance-template","list"],"backgroundTag":"gcp-api-call-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"}