{"record":{"id":"30be7100cdf9268f","repo":"kubernetes/kops","slug":"user-q-not-found","errorCode":null,"errorMessage":"user %q not found","messagePattern":"user %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/files_owner.go","lineNumber":46,"sourceCode":"\n// EnsureFileOwner will set the owner & group for a file.\n// Empty values for owner/group will leave the owner/group unchanged.\nfunc EnsureFileOwner(destPath string, owner string, groupName string) (bool, error) {\n\tchanged := false\n\tstat, err := os.Lstat(destPath)\n\tif err != nil {\n\t\treturn changed, fmt.Errorf(\"error getting file stat for %q: %v\", destPath, err)\n\t}\n\n\tactualUserID := int(stat.Sys().(*syscall.Stat_t).Uid)\n\tuserID := actualUserID\n\tif owner != \"\" {\n\t\tuser, err := LookupUser(owner) // user.Lookup(owner)\n\t\tif err != nil {\n\t\t\treturn changed, fmt.Errorf(\"error looking up user %q: %v\", owner, err)\n\t\t}\n\t\tif user == nil {\n\t\t\treturn changed, fmt.Errorf(\"user %q not found\", owner)\n\t\t}\n\t\tuserID = user.Uid\n\t}\n\n\tactualGroupID := int(stat.Sys().(*syscall.Stat_t).Gid)\n\tgroupID := actualGroupID\n\tif groupName != \"\" {\n\t\tgroup, err := LookupGroup(groupName)\n\t\tif err != nil {\n\t\t\treturn changed, fmt.Errorf(\"error looking up group %q: %v\", groupName, err)\n\t\t}\n\t\tif group == nil {\n\t\t\treturn changed, fmt.Errorf(\"group %q not found\", groupName)\n\t\t}\n\t\tgroupID = group.Gid\n\t}\n\n\tif actualUserID == userID && actualGroupID == groupID {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/files_owner.go#L28-L64","documentation":"EnsureFileOwner sets the unix user/group ownership of a file during local rendering (e.g. node/cluster asset generation). After looking up the requested owner name via LookupUser, if the lookup returns neither an error nor a user, kops treats the username as nonexistent and aborts. This guards against silently leaving a file with the wrong owner when the target user does not exist on the machine.","triggerScenarios":"Calling RenderLocal on a file task whose owner field names a user that does not exist on the local host; LookupUser(owner) succeeds without error but returns nil.","commonSituations":"Cluster spec references a service user (e.g. 'kube') that was never created on the build/admin machine; running kOps in a minimal or containerized environment missing system users; typo in the owner field of a file asset.","solutions":["Create the missing user on the host, e.g. `sudo useradd <name>`","Fix the owner field in the file task/spec to an existing username","Verify with `id <name>` or `getent passwd <name>` that the user resolves locally","If ownership should be left unchanged, set owner to empty string"],"exampleFix":"// before (spec)\nowner: \"kopsadmin\"\n// after (user created or corrected)\nsudo useradd kopsadmin  # or owner: \"\" to skip ownership change","handlingStrategy":"validation","validationCode":"if _, err := user.Lookup(owner); err != nil { return fmt.Errorf(\"user %q does not exist on this host; create it or clear the owner field\", owner) }","typeGuard":null,"tryCatchPattern":"if _, err := ensureFileOwner(path, owner, group); err != nil { if strings.Contains(err.Error(), \"not found\") { /* fall back to default owner or skip */ } else { return err } }","preventionTips":["Run `getent passwd <owner>` in CI before rendering assets","Document required local users for kOps asset rendering","Prefer empty owner field when ownership management is not needed"],"tags":["filesystem","permissions","user-lookup"],"backgroundTag":"user-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}