{"record":{"id":"0f52d3095b78182e","repo":"kubernetes/kops","slug":"error-getting-zone-from-metadata-w","errorCode":null,"errorMessage":"error getting zone from metadata: %w","messagePattern":"error getting zone from metadata: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gce/tpm/gcetpmsigner/tpmauthenticator.go","lineNumber":52,"sourceCode":"\tgcetpm \"k8s.io/kops/upup/pkg/fi/cloudup/gce/tpm\"\n)\n\ntype tpmAuthenticator struct {\n\tprojectID string\n\tzone      string\n\tinstance  string\n}\n\nvar _ bootstrap.Authenticator = (*tpmAuthenticator)(nil)\n\nfunc NewTPMAuthenticator() (bootstrap.Authenticator, error) {\n\tprojectID, err := metadata.ProjectID()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting projectID from metadata: %w\", err)\n\t}\n\tzone, err := metadata.Zone()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting zone from metadata: %w\", err)\n\t}\n\tinstance, err := metadata.InstanceName()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting instance from metadata: %w\", err)\n\t}\n\n\treturn &tpmAuthenticator{\n\t\tprojectID: projectID,\n\t\tzone:      zone,\n\t\tinstance:  instance,\n\t}, nil\n}\n\nfunc (a *tpmAuthenticator) CreateToken(body []byte) (string, error) {\n\trequestHash := sha256.Sum256(body)\n\n\ttpmStart := time.Now()\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gce/tpm/gcetpmsigner/tpmauthenticator.go#L34-L70","documentation":"NewTPMAuthenticator wraps metadata.Zone failure when reading the GCE instance's zone from the metadata server. It fires off-GCE or when the metadata service is unreachable — the TPM-based bootstrap authenticator cannot identify the instance's zone and cannot sign requests.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/gce/tpm/gcetpmsigner/tpmauthenticator.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run on a GCE instance with metadata access","Check metadata server reachability","Inspect the wrapped error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}