{"record":{"id":"c0aee5516be4fad5","repo":"kubernetes/kops","slug":"error-executing-command-q-v-output-s","errorCode":null,"errorMessage":"error executing command %q: %v\nOutput: %s","messagePattern":"error executing command %q: (.+?)\nOutput: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/nodetasks/file.go","lineNumber":325,"sourceCode":"\n\tif changes.Owner != nil || changes.Group != nil {\n\t\townerChanged, err := fi.EnsureFileOwner(e.Path, fi.ValueOf(e.Owner), fi.ValueOf(e.Group))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error changing owner/group on %q: %v\", e.Path, err)\n\t\t}\n\t\tchanged = changed || ownerChanged\n\t}\n\n\tif changed && e.OnChangeExecute != nil {\n\t\tfor _, args := range e.OnChangeExecute {\n\t\t\thuman := strings.Join(args, \" \")\n\n\t\t\tklog.Infof(\"Changed; will execute OnChangeExecute command: %q\", human)\n\n\t\t\tcmd := exec.Command(args[0], args[1:]...)\n\t\t\toutput, err := cmd.CombinedOutput()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error executing command %q: %v\\nOutput: %s\", human, err, output)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":307,"sourceCodeEnd":332,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/nodetasks/file.go#L307-L332","documentation":"During nodeup's RenderLocal for a file task with OnChangeExecute, an associated command was run via exec.Command and returned a non-zero exit status. The error wraps the command string, the exec error (typically 'exit status N'), and the combined stdout/stderr output. It indicates the change hook configured for the file failed on this node.","triggerScenarios":"A File task with OnChangeExecute set is rendered, its contents/permissions changed, and the configured command (e.g. systemctl reload, postinstall script) exits non-zero.","commonSituations":"A post-change script references a binary not yet installed on the node; a service being reloaded is not running; a script has a syntax error or wrong path after image changes.","solutions":["Inspect the Output: section of the error for the underlying command failure","Run the same command manually on the node to reproduce and debug","Fix the OnChangeExecute command path/args in the file task definition","Verify required binaries/services exist at the time nodeup runs"],"exampleFix":"// before\nonChange := \"/usr/local/sbin/reload-thing\"\n// after\n// ensure the script exists and is executable, or guard it:\nonChange = \"[ -x /usr/local/sbin/reload-thing ] && /usr/local/sbin/reload-thing || true\"","handlingStrategy":"try-catch","validationCode":"// before invoking nodeup, sanity-check OnChangeExecute targets exist in the image\nif !fileExists(node, \"/usr/local/sbin/reload-thing\") { t.Fatalf(\"OnChangeExecute target missing\") }","typeGuard":null,"tryCatchPattern":"if err := task.RenderLocal(ctx, a, b); err != nil {\n  if strings.Contains(err.Error(), \"error executing command\") {\n    // parse 'Output:' section, log command output, decide on retry/abort\n  }\n  return err\n}","preventionTips":["Keep OnChangeExecute commands idempotent and present in the base image","Test file tasks with OnChangeExecute in a VM before rollout","Read the Output: section first — it contains the real failure"],"tags":["nodeup","exec","command-failed"],"backgroundTag":"exec-command-nonzero-exit","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"}