{"record":{"id":"1a1bec4ed2107abb","repo":"kubernetes/kops","slug":"unable-to-find-instance-in-compute-api-w","errorCode":null,"errorMessage":"unable to find instance in compute API: %w","messagePattern":"unable to find instance in compute API: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gce/tpm/gcetpmverifier/tpmverifier.go","lineNumber":132,"sourceCode":"\tif tokenData.GCPProjectID == \"\" {\n\t\treturn nil, fmt.Errorf(\"gcpProjectID is required\")\n\t}\n\tif tokenData.Zone == \"\" {\n\t\treturn nil, fmt.Errorf(\"zone is required\")\n\t}\n\tif tokenData.Instance == \"\" {\n\t\treturn nil, fmt.Errorf(\"instance is required\")\n\t}\n\n\t// Verify node is in our cluster\n\tif tokenData.GCPProjectID != v.opt.ProjectID {\n\t\treturn nil, fmt.Errorf(\"projectID does not match expected: got %q, want %q\", tokenData.GCPProjectID, v.opt.ProjectID)\n\t}\n\n\tinstance, err := v.computeClient.Instances.Get(tokenData.GCPProjectID, tokenData.Zone, tokenData.Instance).Context(ctx).Do()\n\tif err != nil {\n\t\tif isNotFound(err) {\n\t\t\treturn nil, fmt.Errorf(\"unable to find instance in compute API: %w\", err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error fetching instance from compute API: %w\", err)\n\t}\n\n\tif !strings.HasPrefix(lastComponent(instance.Zone), v.opt.Region+\"-\") {\n\t\treturn nil, fmt.Errorf(\"instance was in zone %q, expected region %q\", instance.Zone, v.opt.Region)\n\t}\n\n\tclusterName := \"\"\n\tinstanceGroupName := \"\"\n\tfor _, item := range instance.Metadata.Items {\n\t\tswitch item.Key {\n\t\tcase gce.MetadataKeyInstanceGroupName:\n\t\t\tinstanceGroupName = fi.ValueOf(item.Value)\n\t\tcase gcemetadata.MetadataKeyClusterName:\n\t\t\tclusterName = fi.ValueOf(item.Value)\n\t\t}\n\t}","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gce/tpm/gcetpmverifier/tpmverifier.go#L114-L150","documentation":"The verifier wraps a googleapi NotFound error (HTTP 404) from computeClient.Instances.Get: the VM named in the token does not exist in the given project/zone. This prevents deleted or fabricated instance identities from authenticating.","triggerScenarios":"Instances.Get(project, zone, instance) returns 404 — the instance was deleted, never existed, or the token names the wrong zone/instance combination.","commonSituations":"Node deleted/recreated (new VM name) while presenting an old token, tokens minted with partial zone paths or wrong zone, stale node records after cluster resize, or cross-region typos in configuration.","solutions":["Verify the instance exists: `gcloud compute instances describe <name> --zone <zone> --project <project>`.","Regenerate the token on the (recreated) node so it carries the current instance name and zone.","Check the token producer reads the correct `instance/name` and `instance/zone` metadata values."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"_, err := computeClient.Instances.Get(project, zone, instance).Context(ctx).Do()\nif err != nil {\n\treturn fmt.Errorf(\"instance %s/%s not found before requesting token: %w\", zone, instance, err)\n}","typeGuard":null,"tryCatchPattern":"var notFound *googleapi.Error\nif errors.As(err, &notFound) && notFound.Code == 404 {\n\t// regenerate token / re-provision node\n}","preventionTips":["Regenerate tokens after node recreation","Verify instance names/zones with gcloud before enrolling nodes","Clean up stale node records after cluster resize"],"tags":["gcp","compute-api","authentication","not-found"],"backgroundTag":"resource-not-found","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"}