{"record":{"id":"8e1addd87c01b458","repo":"kubernetes/kops","slug":"couldn-t-determine-hostname-w","errorCode":null,"errorMessage":"couldn't determine hostname: %w","messagePattern":"couldn't determine hostname: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/pkibootstrap/pkisigner.go","lineNumber":89,"sourceCode":"\nfunc computeKeyID(signer crypto.Signer) (string, error) {\n\tpublicKey := signer.Public()\n\tpkData, err := x509.MarshalPKIXPublicKey(publicKey)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error converting public key to x509: %w\", err)\n\t}\n\n\tvar b bytes.Buffer\n\tif err := pem.Encode(&b, &pem.Block{Type: \"PUBLIC KEY\", Bytes: pkData}); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error encoding public key: %w\", err)\n\t}\n\treturn b.String(), nil\n}\n\nfunc NewAuthenticatorFromFile(p string) (bootstrap.Authenticator, error) {\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't determine hostname: %w\", err)\n\t}\n\n\tkeyBytes, err := os.ReadFile(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading %q: %w\", p, err)\n\t}\n\tkey, err := pki.ParsePEMPrivateKey(keyBytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing key from %q: %w\", p, err)\n\t}\n\n\treturn NewAuthenticator(hostname, key.Key)\n}\n\nfunc (a *pkiAuthenticator) CreateToken(body []byte) (string, error) {\n\trequestHash := sha256.Sum256(body)\n\n\tdata := AuthTokenData{","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/pkibootstrap/pkisigner.go#L71-L107","documentation":"os.Hostname() failed while building a file-based PKI authenticator: the kernel returned an error for gethostname, so the instance identity embedded in auth tokens cannot be determined. The path/key-file arguments are only processed after this.","triggerScenarios":"Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Investigate why the node's hostname is unobtainable (UTS namespace or container sandbox restrictions)","Set a valid hostname on the host and retry","If running in a constrained container, ensure the sandbox permits hostname syscalls"],"exampleFix":null,"handlingStrategy":"fallback","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"}