hashicorp/nomad · error
oom_score_adj must not be negative
Error message
oom_score_adj must not be negative
What it means
rawexec's TaskConfig.validate() rejects a negative oom_score_adj. The value maps directly to the Linux kernel's /proc/<pid>/oom_score_adj, which must be within [-1000, 1000]; Nomad's driver enforces non-negative values to prevent tasks from being made immune to the OOM killer.
Source
Thrown at drivers/rawexec/driver.go:198
// OOMScoreAdj sets the oom_score_adj on Linux systems
OOMScoreAdj int `codec:"oom_score_adj"`
// WorkDir sets the working directory of the task
WorkDir string `codec:"work_dir"`
//DeniedEnvvars enables the removal of specified environment variables from a given job environment
DeniedEnvvars []string `codec:"denied_envvars"`
}
func (t *TaskConfig) validate() error {
// ensure only one of cgroups_v1_override and cgroups_v2_override have been
// configured; must check here because task config validation cannot happen
// on the server.
if len(t.OverrideCgroupV1) > 0 && t.OverrideCgroupV2 != "" {
return errors.New("only one of cgroups_v1_override and cgroups_v2_override may be set")
}
if t.OOMScoreAdj < 0 {
return errors.New("oom_score_adj must not be negative")
}
if t.WorkDir != "" && !filepath.IsAbs(t.WorkDir) {
return errors.New("work_dir must be an absolute path")
}
return nil
}
// TaskState is the state which is encoded in the handle returned in
// StartTask. This information is needed to rebuild the task state and handler
// during recovery.
type TaskState struct {
ReattachConfig *pstructs.ReattachConfig
TaskConfig *drivers.TaskConfig
Pid int
StartedAt time.Time
}
// NewRawExecDriver returns a new DriverPlugin implementationView on GitHub (pinned to 482b49bf1a)
Solutions
- Set oom_score_adj to 0 or a positive value (e.g. 100–1000) as required by the driver
- Remove oom_score_adj entirely to inherit the default score
- If the process truly must be OOM-protected, run it outside Nomad or adjust at the system level with the appropriate privileges
- Review Nomad docs for the allowed oom_score_adj range in your version
Example fix
// before
config {
command = "/bin/app"
oom_score_adj = -500
}
// after
config {
command = "/bin/app"
oom_score_adj = 500
} Defensive patterns
Strategy: validation
Validate before calling
func checkOomScoreAdj(v *int) error {
if v != nil && *v < 0 {
return errors.New("oom_score_adj must be >= 0")
}
return nil
} Type guard
func validOomScore(v int) bool { return v >= 0 } Prevention
- Remember Nomad only accepts non-negative oom_score_adj
- Do not copy Linux/sysadmin negative values into rawexec configs
- Review rawexec task schema when upgrading Nomad versions
When it happens
Trigger: Submitting a rawexec task with oom_score_adj set to a negative integer in the driver config; validate() runs at task-config parse time on the client.
Common situations: Operators trying to protect critical processes from the OOM killer copy Linux admin advice that uses negative values; typo like "oom_score_adj = -100" from an older systemd unit config; misunderstanding of Nomad's intentionally stricter validation.
Related errors
- only one of cgroups_v1_override and cgroups_v2_override may
- work_dir must be an absolute path
- failed to parse config:
- rpc.dial_timeout must be greater than or equal to zero
- client_introduction.enforcement must be set
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/f8c2021b35765533.
Report an issue: GitHub.