kubernetes/kops · error
error creating user: %v Output: %s
Error message
error creating user: %v Output: %s
What it means
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.
Source
Thrown at upup/pkg/fi/nodeup/nodetasks/user.go:101
if e.Shell != "" {
args = append(args, "-s", e.Shell)
}
if e.Home != "" {
args = append(args, "-d", e.Home)
}
args = append(args, e.Name)
return args
}
func (_ *UserTask) RenderLocal(t *local.LocalTarget, a, e, changes *UserTask) error {
if a == nil {
args := buildUseraddArgs(e)
klog.Infof("Creating user %q", e.Name)
cmd := exec.Command("useradd", args...)
klog.V(2).Infof("running command: useradd %s", strings.Join(args, " "))
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("error creating user: %v\nOutput: %s", err, output)
}
} else {
var args []string
if changes.UID != 0 {
args = append(args, "-u", strconv.Itoa(e.UID))
}
if changes.Shell != "" {
args = append(args, "-s", e.Shell)
}
if changes.Home != "" {
args = append(args, "-d", e.Home)
}
if len(args) != 0 {
args = append(args, e.Name)
klog.Infof("Reconfiguring user %q", e.Name)
cmd := exec.Command("usermod", args...)View on GitHub (pinned to 4c8573c808)
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
Example fix
// before: cluster spec UserTask: Name "jenkins", UID 1000 # 1000 taken by image default user // after UserTask: Name "jenkins", UID 1100 # free UID on the image
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check UID availability and useradd presence before nodeup: command -v useradd >/dev/null || echo 'useradd missing' id -u jenkins >/dev/null 2>&1 && echo 'user exists' getent passwd 1100 >/dev/null && echo 'UID taken' || echo 'UID free'
Try / catch
if err := task.RenderLocal(...); err != nil {
if strings.Contains(err.Error(), "error creating user") {
// Output embedded in error says why (exists / UID conflict)
return fmt.Errorf("useradd failed; reconcile user state: %w", err)
}
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- error executing command %q: %v Output: %s
- error doing systemd daemon-reload: %v Output: %s
- error doing systemd %s %s: %v Output: %s
- error doing 'systemctl %v': %v Output: %s
- error running kubectl: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/55f4b7c50aba0664.
Report an issue: GitHub.