{"record":{"id":"55f4b7c50aba0664","repo":"kubernetes/kops","slug":"error-creating-user-v-output-s","errorCode":null,"errorMessage":"error creating user: %v\nOutput: %s","messagePattern":"error creating user: (.+?)\nOutput: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/nodetasks/user.go","lineNumber":101,"sourceCode":"\tif e.Shell != \"\" {\n\t\targs = append(args, \"-s\", e.Shell)\n\t}\n\tif e.Home != \"\" {\n\t\targs = append(args, \"-d\", e.Home)\n\t}\n\targs = append(args, e.Name)\n\treturn args\n}\n\nfunc (_ *UserTask) RenderLocal(t *local.LocalTarget, a, e, changes *UserTask) error {\n\tif a == nil {\n\t\targs := buildUseraddArgs(e)\n\t\tklog.Infof(\"Creating user %q\", e.Name)\n\t\tcmd := exec.Command(\"useradd\", args...)\n\t\tklog.V(2).Infof(\"running command: useradd %s\", strings.Join(args, \" \"))\n\t\toutput, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error creating user: %v\\nOutput: %s\", err, output)\n\t\t}\n\t} else {\n\t\tvar args []string\n\n\t\tif changes.UID != 0 {\n\t\t\targs = append(args, \"-u\", strconv.Itoa(e.UID))\n\t\t}\n\t\tif changes.Shell != \"\" {\n\t\t\targs = append(args, \"-s\", e.Shell)\n\t\t}\n\t\tif changes.Home != \"\" {\n\t\t\targs = append(args, \"-d\", e.Home)\n\t\t}\n\n\t\tif len(args) != 0 {\n\t\t\targs = append(args, e.Name)\n\t\t\tklog.Infof(\"Reconfiguring user %q\", e.Name)\n\t\t\tcmd := exec.Command(\"usermod\", args...)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/nodetasks/user.go#L83-L119","documentation":"The User task's RenderLocal creates the account by exec'ing `useradd` with built args and capturing combined output; a non-zero useradd exit becomes this error with useradd's own diagnostics appended, so the account creation is reported as a task failure.","triggerScenarios":"exec.Command(\"useradd\", buildUseraddArgs(e)...) returns error: UID/GID already in use, username already exists, invalid -u/-g values, home directory conflicts, or useradd binary missing (e.g. on distros using adduser only).","commonSituations":"Cluster spec pins a UID that collides with an image-baked user, a previous partially-failed nodeup left the user created so a rerun hits 'already exists', or minimal images (some Debian slim/alpine-style) lacking useradd.","solutions":["Read the Output section — useradd messages like 'UID 1001 is not unique' or 'already exists' point to the exact conflict","If the user already exists with the right properties, reconcile state (remove and let nodeup recreate, or fix the task's Find/actual-state detection) and re-run","Choose a non-conflicting UID/Name in the cluster spec (InstanceGroup/userData) and re-run nodeup","Ensure the image ships the shadow-utils package providing /usr/sbin/useradd","Check /etc/login.defs constraints if useradd complains about ranges or home dirs"],"exampleFix":"// before: cluster spec\nUserTask: Name \"jenkins\", UID 1000  # 1000 taken by image default user\n// after\nUserTask: Name \"jenkins\", UID 1100  # free UID on the image","handlingStrategy":"try-catch","validationCode":"// Pre-check UID availability and useradd presence before nodeup:\ncommand -v useradd >/dev/null || echo 'useradd missing'\nid -u jenkins >/dev/null 2>&1 && echo 'user exists'\ngetent passwd 1100 >/dev/null && echo 'UID taken' || echo 'UID free'","typeGuard":null,"tryCatchPattern":"if err := task.RenderLocal(...); err != nil {\n\tif strings.Contains(err.Error(), \"error creating user\") {\n\t\t// Output embedded in error says why (exists / UID conflict)\n\t\treturn fmt.Errorf(\"useradd failed; reconcile user state: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Pick UIDs that don't collide with image-baked users","Ensure shadow-utils/useradd exists on the image","Reconcile after partial nodeup failures so reruns see consistent state","Keep names/UIDs in the spec within /etc/login.defs ranges"],"tags":["nodeup","useradd","linux-users","exec"],"backgroundTag":"useradd-failed","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"}