{"record":{"id":"aa441bdd35a1f5b7","repo":"hashicorp/nomad","slug":"execstreaming-w","errorCode":null,"errorMessage":"ExecStreaming: %w","messagePattern":"ExecStreaming: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor.go","lineNumber":540,"sourceCode":"\t\t\tcmd.Stdout = tty\n\t\t\tcmd.Stderr = tty\n\t\t\treturn nil\n\t\t},\n\t\tsetIO: func(stdin io.Reader, stdout, stderr io.Writer) error {\n\t\t\tcmd.Stdin = stdin\n\t\t\tcmd.Stdout = stdout\n\t\t\tcmd.Stderr = stderr\n\t\t\treturn nil\n\t\t},\n\t\tprocessStart: func() error {\n\t\t\tif u := e.command.User; u != \"\" {\n\t\t\t\tif err := setCmdUser(cmd, u); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tcgroup := e.command.StatsCgroup()\n\t\t\tif cleanup, err := e.setSubCmdCgroup(cmd, cgroup); err != nil {\n\t\t\t\treturn fmt.Errorf(\"ExecStreaming: %w\", err)\n\t\t\t} else {\n\t\t\t\tdefer cleanup()\n\t\t\t}\n\t\t\treturn withNetworkIsolation(cmd.Start, e.command.NetworkIsolation)\n\t\t},\n\t\tprocessWait: func() (*os.ProcessState, error) {\n\t\t\terr := cmd.Wait()\n\t\t\treturn cmd.ProcessState, err\n\t\t},\n\t}\n\n\treturn execHelper.run(ctx, tty, stream)\n}\n\n// Wait waits until a process has exited and returns it's exitcode and errors\nfunc (e *UniversalExecutor) Wait(ctx context.Context) (*ProcessState, error) {\n\tselect {\n\tcase <-ctx.Done():","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor.go#L522-L558","documentation":"Wraps errors from setSubCmdCgroup, which assigns a stats cgroup to the streamed sub-command during ExecStreaming. If cgroup setup fails (writing the PID to the cgroup's procs file, opening the cgroup path, permissions), the error is wrapped with the 'ExecStreaming:' prefix. It indicates the process could not be placed into the required control group.","triggerScenarios":"Calling ExecStreaming on Linux when command.StatsCgroup() returns a cgroup that cannot be set up: cgroup path missing, cgroup filesystem not mounted/writable, or driver lacks permission (not running as root or without cgroup delegation).","commonSituations":"Nomad client running in a container without cgroup access; cgroup v1 vs v2 mismatch; systemd cgroup driver cleanup removed the cgroup before streaming started; running the agent unprivileged.","solutions":["Verify the client has write access to the cgroup hierarchy (run with sufficient privileges, mount cgroups into containers)","Check the cgroup path returned by StatsCgroup() exists at the time of the call","Inspect the wrapped inner error (%w) for the exact cgroup operation that failed","If cgroup stats are unnecessary, verify the driver/client cgroup config is consistent"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check cgroup writability on Linux\nif runtime.GOOS == \"linux\" && cgroupPath != \"\" {\n    if _, err := os.Stat(filepath.Join(cgroupPath, \"cgroup.procs\")); err != nil {\n        return fmt.Errorf(\"cgroup not usable: %w\", err)\n    }\n}","typeGuard":"func cgroupWritable(path string) bool {\n    fi, err := os.Stat(filepath.Join(path, \"cgroup.procs\"))\n    return err == nil && !fi.IsDir()\n}","tryCatchPattern":"if err := e.ExecStreaming(ctx, cmd, tty, stream); err != nil {\n    var wrappedErr error\n    if strings.Contains(err.Error(), \"ExecStreaming:\") {\n        errors.As(err, &wrappedErr)\n        return fmt.Errorf(\"cgroup placement failed: %w\", wrappedErr)\n    }\n    return err\n}","preventionTips":["Run the Nomad client with cgroup access (root or delegated cgroup v2)","Mount cgroup filesystems into client containers","Keep cgroup v1/v2 usage consistent with host configuration"],"tags":["cgroup","linux","executor"],"backgroundTag":"cgroup-setup-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}