{"record":{"id":"2a01f13b2a097b43","repo":"kubernetes/kops","slug":"error-listing-instances-v-2a01f1","errorCode":null,"errorMessage":"error listing Instances: %v","messagePattern":"error listing Instances: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instance.go","lineNumber":74,"sourceCode":"\n\tmetadataFingerprint string\n}\n\nvar _ fi.CompareWithID = (*Instance)(nil)\n\nfunc (e *Instance) CompareWithID() *string {\n\treturn e.Name\n}\n\nfunc (e *Instance) Find(c *fi.CloudupContext) (*Instance, error) {\n\tcloud := c.T.Cloud.(gce.GCECloud)\n\n\tr, err := cloud.Compute().Instances().Get(cloud.Project(), *e.Zone, *e.Name)\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 Instances: %v\", err)\n\t}\n\n\tactual := &Instance{}\n\tactual.Name = &r.Name\n\tactual.Tags = append(actual.Tags, r.Tags.Items...)\n\tactual.Zone = new(lastComponent(r.Zone))\n\tactual.MachineType = new(lastComponent(r.MachineType))\n\tactual.CanIPForward = &r.CanIpForward\n\tif r.Scheduling != nil {\n\t\tactual.Preemptible = &r.Scheduling.Preemptible\n\t}\n\tif len(r.NetworkInterfaces) != 0 {\n\t\tni := r.NetworkInterfaces[0]\n\t\tactual.Network = &Network{Name: new(lastComponent(ni.Network))}\n\t\tactual.StackType = &ni.StackType\n\t\tif len(ni.AccessConfigs) != 0 {\n\t\t\tac := ni.AccessConfigs[0]\n\t\t\tif ac.NatIP != \"\" {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instance.go#L56-L92","documentation":"In the GCE Instance task's Find, kOps fetches the instance with Instances().Get. If the call fails with anything other than a NotFound, the error is wrapped as 'error listing Instances'. It means the instance lookup itself failed at the GCE API level, not that the instance is absent.","triggerScenarios":"Instances().Get(project, zone, name) returns a non-NotFound error: invalid/unknown zone, permission denied on the compute API, API disabled, network failure, or quota/billing issues.","commonSituations":"Zone removed or mis-set in the state vs. current project, Compute Engine API disabled for the project, service account lacking compute.instances.get IAM permission, or transient API outages during `kops update cluster --refresh`.","solutions":["Read the wrapped %v error to identify the underlying GCE API failure","Verify the zone in the instance spec/state exists: `gcloud compute zones list`","Enable the Compute Engine API and check IAM: service account needs compute.viewer (compute.instances.get)","Retry if the error is transient (429/5xx)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the zone and API access before the Get call\ncmd := exec.Command(\"gcloud\", \"compute\", \"instances\", \"describe\", *e.Name,\n\t\"--zone\", *e.Zone, \"--project\", cloud.Project(), \"--format=value(name)\")\nif err := cmd.Run(); err != nil {\n\treturn fmt.Errorf(\"precheck: instance %s not accessible in zone %s: %w\", *e.Name, *e.Zone, err)\n}","typeGuard":"func isNotFound(err error) bool { return err != nil && gce.IsNotFound(err) }\nfunc isPermissionDenied(err error) bool {\n\tvar ge *googleapi.Error\n\treturn errors.As(err, &ge) && ge.Code == 403\n}","tryCatchPattern":"r, err := cloud.Compute().Instances().Get(cloud.Project(), *e.Zone, *e.Name)\nif err != nil {\n\tif gce.IsNotFound(err) { return nil, nil }\n\tvar ge *googleapi.Error\n\tif errors.As(err, &ge) && (ge.Code == 429 || ge.Code >= 500) {\n\t\treturn nil, retry.Wrapf(err, \"transient; retry with backoff\")\n\t}\n\treturn nil, fmt.Errorf(\"error listing Instances: %v\", err)\n}","preventionTips":["Pin instance zone in the spec and confirm it exists in the target project","Enable Compute Engine API before running kops","Grant the kops service account compute.viewer at project level","Use `gcloud compute instances describe` to reproduce API-level failures outside kops"],"tags":["gce","instance","api-error"],"backgroundTag":"gce-api-request-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"}