hashicorp/nomad · error

ExecStreaming: %w

Error message

ExecStreaming: %w

What it means

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.

Source

Thrown at drivers/shared/executor/executor.go:540

			cmd.Stdout = tty
			cmd.Stderr = tty
			return nil
		},
		setIO: func(stdin io.Reader, stdout, stderr io.Writer) error {
			cmd.Stdin = stdin
			cmd.Stdout = stdout
			cmd.Stderr = stderr
			return nil
		},
		processStart: func() error {
			if u := e.command.User; u != "" {
				if err := setCmdUser(cmd, u); err != nil {
					return err
				}
			}
			cgroup := e.command.StatsCgroup()
			if cleanup, err := e.setSubCmdCgroup(cmd, cgroup); err != nil {
				return fmt.Errorf("ExecStreaming: %w", err)
			} else {
				defer cleanup()
			}
			return withNetworkIsolation(cmd.Start, e.command.NetworkIsolation)
		},
		processWait: func() (*os.ProcessState, error) {
			err := cmd.Wait()
			return cmd.ProcessState, err
		},
	}

	return execHelper.run(ctx, tty, stream)
}

// Wait waits until a process has exited and returns it's exitcode and errors
func (e *UniversalExecutor) Wait(ctx context.Context) (*ProcessState, error) {
	select {
	case <-ctx.Done():

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Verify the client has write access to the cgroup hierarchy (run with sufficient privileges, mount cgroups into containers)
  2. Check the cgroup path returned by StatsCgroup() exists at the time of the call
  3. Inspect the wrapped inner error (%w) for the exact cgroup operation that failed
  4. If cgroup stats are unnecessary, verify the driver/client cgroup config is consistent
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check cgroup writability on Linux
if runtime.GOOS == "linux" && cgroupPath != "" {
    if _, err := os.Stat(filepath.Join(cgroupPath, "cgroup.procs")); err != nil {
        return fmt.Errorf("cgroup not usable: %w", err)
    }
}

Type guard

func cgroupWritable(path string) bool {
    fi, err := os.Stat(filepath.Join(path, "cgroup.procs"))
    return err == nil && !fi.IsDir()
}

Try / catch

if err := e.ExecStreaming(ctx, cmd, tty, stream); err != nil {
    var wrappedErr error
    if strings.Contains(err.Error(), "ExecStreaming:") {
        errors.As(err, &wrappedErr)
        return fmt.Errorf("cgroup placement failed: %w", wrappedErr)
    }
    return err
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/aa441bdd35a1f5b7. Report an issue: GitHub.