{"record":{"id":"f06e2f71edb4106f","repo":"kubernetes/kops","slug":"error-getting-instance-v","errorCode":null,"errorMessage":"error getting Instance: %v","messagePattern":"error getting Instance: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gce/instancegroups.go","lineNumber":209,"sourceCode":"\t\t\t\tMaxSize:       int(mig.TargetSize),\n\t\t\t\tRaw:           mig,\n\t\t\t}\n\t\t\tgroups[mig.Name] = g\n\n\t\t\tlatestInstanceTemplate := mig.InstanceTemplate\n\n\t\t\tinstances, err := ListManagedInstances(c, mig)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tfor _, i := range instances {\n\t\t\t\tid := i.Instance\n\t\t\t\tname := LastComponent(id)\n\t\t\t\tinstance, err := c.Compute().Instances().Get(project, zoneName, name)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif !IsNotFound(err) {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"error getting Instance: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tklog.Warningf(\"Instance %s not found, it may not have been created\", name)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tcm := &cloudinstances.CloudInstance{\n\t\t\t\t\tID:                 instance.SelfLink,\n\t\t\t\t\tCloudInstanceGroup: g,\n\t\t\t\t}\n\t\t\t\taddCloudInstanceData(cm, instance)\n\n\t\t\t\t// Try first by provider ID\n\t\t\t\tproviderID := \"gce://\" + project + \"/\" + zoneName + \"/\" + name\n\t\t\t\tnode := nodesByProviderID[providerID]\n\n\t\t\t\tif node != nil {\n\t\t\t\t\tcm.Node = node\n\t\t\t\t} else {\n\t\t\t\t\tklog.V(8).Infof(\"unable to find node for instance: %s\", id)","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gce/instancegroups.go#L191-L227","documentation":"Returned by GetCloudGroups when fetching details of an individual member instance of a MIG via Compute().Instances().Get() fails with a non-not-found error. Not-found is intentionally tolerated (logged as a warning since the instance may not be created yet); any other API error aborts listing the cloud groups.","triggerScenarios":"Calling GetCloudGroups where Instances().Get(project, zoneName, name) errors on a MIG member: permission denied on compute.instances.get, invalid instance name derived from the self-link, API rate limiting, or transient GCE outage.","commonSituations":"Large clusters hitting GCE API rate limits during listing, IAM role changes removing compute.viewer, instances in the middle of creation/deletion returning unexpected errors, or corrupted instance self-links after manual console edits.","solutions":["Read the wrapped cause: 403 -> restore compute.instances.get IAM permission for the kops service account.","Retry on 429/5xx — this is often transient rate limiting when listing many instances across zones.","Verify the instance exists in the expected zone (gcloud compute instances describe <name> --zone <zone>).","If the instance is a zombie (MIG says member, GCE says otherwise), recreate the MIG members via rolling-update."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"error getting Instance: %v\", err)\n// after\ngerr, ok := err.(*googleapi.Error)\nif ok && gerr.Code == 429 {\n    return nil, fmt.Errorf(\"rate limited getting Instance %s; retry: %v\", name, err)\n}\nreturn nil, fmt.Errorf(\"error getting Instance: %v\", err)","handlingStrategy":"retry","validationCode":"// verify each MIG member is fetchable before bulk operations\nfor _, inst := range migMembers {\n    if _, err := computeService.Instances.Get(project, zone, inst.Name).Do(); err != nil {\n        log.Warnf(\"instance %s in zone %s not fetchable: %v\", inst.Name, zone, err)\n    }\n}","typeGuard":"func isNotFoundOrAbsent(err error) bool {\n    var gerr *googleapi.Error\n    return errors.As(err, &gerr) && (gerr.Code == 404 || gerr.Code == 400)\n}","tryCatchPattern":"instance, err := c.Compute().Instances().Get(project, zone, name)\nif err != nil {\n    if isNotFoundOrAbsent(err) {\n        log.Warnf(\"Instance %s not found, skipping\", name)\n        continue\n    }\n    if isGoogleAPIErr(err, 429) || isGoogleAPIErr(err, 500) {\n        // backoff and retry the Get\n    }\n    return nil, fmt.Errorf(\"error getting Instance: %v\", err)\n}","preventionTips":["Avoid IAM changes that remove compute.instances.get during cluster operations.","Batch/space out API calls when listing instances across many zones to avoid rate limits.","Re-run the command after transient 5xx/429 failures.","Reconcile zombie instances (listed by MIG but absent in GCE) with a rolling-update."],"tags":["gce","gcp","instances","api-error","kops"],"backgroundTag":"gce-instance-get-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"}