mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
e2e: add test for raw_exec memory_max configuration (#19596)
* e2e: add test for raw_exec memory_max configuration * docs: note raw_exec supports memory_max in resources documentation
This commit is contained in:
38
e2e/rawexec/input/oversub.hcl
Normal file
38
e2e/rawexec/input/oversub.hcl
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
job "oversub" {
|
||||
type = "batch"
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.kernel.name}"
|
||||
value = "linux"
|
||||
}
|
||||
|
||||
group "group" {
|
||||
reschedule {
|
||||
attempts = 0
|
||||
unlimited = false
|
||||
}
|
||||
|
||||
restart {
|
||||
attempts = 0
|
||||
mode = "fail"
|
||||
}
|
||||
|
||||
task "cat" {
|
||||
driver = "raw_exec"
|
||||
|
||||
config {
|
||||
command = "bash"
|
||||
args = ["-c", "cat /sys/fs/cgroup/$(cat /proc/self/cgroup | cut -d':' -f3)/memory.max"]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 100
|
||||
memory = 64
|
||||
memory_max = 128
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ func TestRawExec(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Run("testOomAdj", testOomAdj)
|
||||
t.Run("testOversubMemory", testOversubMemory)
|
||||
}
|
||||
|
||||
func testOomAdj(t *testing.T) {
|
||||
@@ -27,3 +28,11 @@ func testOomAdj(t *testing.T) {
|
||||
logs := job.TaskLogs("group", "cat")
|
||||
must.StrContains(t, logs.Stdout, "0")
|
||||
}
|
||||
|
||||
func testOversubMemory(t *testing.T) {
|
||||
job, cleanup := jobs3.Submit(t, "./input/oversub.hcl")
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
logs := job.TaskLogs("group", "cat")
|
||||
must.StrContains(t, logs.Stdout, "134217728") // 128 mb memory_max
|
||||
}
|
||||
|
||||
@@ -116,8 +116,9 @@ mechanism for memory pressure is specific to the task driver, operating system,
|
||||
and application runtime.
|
||||
|
||||
The `memory_max` limit attribute is currently supported by the official
|
||||
`docker`, `exec`, and `java` task drivers. Consult the documentation of
|
||||
community-supported task drivers for their memory oversubscription support.
|
||||
`raw_exec`, `docker`, `exec`, and `java` task drivers. Consult the
|
||||
documentation of community-supported task drivers for their memory
|
||||
oversubscription support.
|
||||
|
||||
Memory oversubscription is opt-in. Nomad operators can enable [Memory
|
||||
Oversubscription in the scheduler configuration][api_sched_config]. Enterprise
|
||||
|
||||
Reference in New Issue
Block a user