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:
Seth Hoenig
2024-01-04 08:25:56 -06:00
committed by GitHub
parent aa197cf824
commit ccfb13a72d
3 changed files with 50 additions and 2 deletions

View 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
}
}
}
}

View File

@@ -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
}

View File

@@ -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