{"record":{"id":"702134b1062d2d14","repo":"kubernetes/kops","slug":"error-getting-projectid-from-metadata-w","errorCode":null,"errorMessage":"error getting projectID from metadata: %w","messagePattern":"error getting projectID from metadata: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gce/tpm/gcetpmsigner/tpmauthenticator.go","lineNumber":48,"sourceCode":"\t\"cloud.google.com/go/compute/metadata\"\n\t\"github.com/google/go-tpm-tools/client\"\n\t\"k8s.io/klog/v2\"\n\t\"k8s.io/kops/pkg/bootstrap\"\n\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) {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gce/tpm/gcetpmsigner/tpmauthenticator.go#L30-L66","documentation":"Wraps metadata.ProjectID failure in the GCE TPM authenticator: the project ID could not be read from the instance metadata server. Fires when the process is not running on a GCE instance or the metadata server is unreachable.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/gce/tpm/gcetpmsigner/tpmauthenticator.go:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the authenticator on a GCE instance","Check metadata server connectivity (169.254.169.254)","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"}