diff --git a/packages/system/linstor/templates/cluster.yaml b/packages/system/linstor/templates/cluster.yaml index ba5154375..a6dd27d6d 100644 --- a/packages/system/linstor/templates/cluster.yaml +++ b/packages/system/linstor/templates/cluster.yaml @@ -40,7 +40,8 @@ spec: - name: linstor-controller image: {{ .Values.piraeusServer.image.repository }}:{{ .Values.piraeusServer.image.tag }} # Guarantee CPU/memory so the JVM keeps answering its /health probe - # under node contention. Requests only — see values.yaml controller.*. + # under node contention, with a memory ceiling above the -Xmx the image + # was built with and no CPU ceiling — see values.yaml controller.*. resources: {{- toYaml .Values.controller.resources | nindent 12 }} # Partial override: piraeus-operator merges podTemplate as a strategic diff --git a/packages/system/linstor/tests/cluster_test.yaml b/packages/system/linstor/tests/cluster_test.yaml index 4bf7ba094..96e192fe6 100644 --- a/packages/system/linstor/tests/cluster_test.yaml +++ b/packages/system/linstor/tests/cluster_test.yaml @@ -5,8 +5,15 @@ suite: LinstorCluster controller resources and liveness hardening # into the generated linstor-controller Deployment as a strategic merge patch # (containers merged by name, struct fields merged field-by-field), so: # - resources.requests guarantee the JVM gets scheduled CPU/memory so it can -# answer GET /health under node CPU contention (no limits: avoid throttling -# / OOM-killing the JVM); +# answer GET /health under node CPU contention, and CPU stays unlimited to +# avoid throttling it; +# - resources.limits.memory is stated on purpose and has to stay above the +# -Xmx8G baked into the image (build.gradle, jvmControllerOpts), which the +# JVM honours without ever reading its cgroup. It is pinned here because two +# separate things would silently break it: lowering it below 8G hands the +# kernel a process that will grow past it, and removing it hands the +# container to the system-namespace LimitRange cozystack-operator maintains, +# whose 4Gi default is half that heap ceiling; # - the livenessProbe override carries ONLY the timing fields (timeoutSeconds, # failureThreshold) relaxed from the operator defaults (1s / 3) so a JVM GC # pause or CPU contention does not trip a liveness kill. The httpGet target @@ -17,7 +24,7 @@ templates: - templates/cluster.yaml tests: - - it: "linstor-controller container carries CPU and memory requests (no limits)" + - it: "linstor-controller container carries CPU and memory requests, and a memory limit above the baked-in -Xmx8G" asserts: - isKind: of: LinstorCluster @@ -30,8 +37,13 @@ tests: - equal: path: spec.controller.podTemplate.spec.containers[0].resources.requests.memory value: 700Mi + - equal: + path: spec.controller.podTemplate.spec.containers[0].resources.limits.memory + value: 10Gi + # CPU stays unlimited: the memory ceiling is what the JVM forces, throttling + # the controller's event loop is not. - notExists: - path: spec.controller.podTemplate.spec.containers[0].resources.limits + path: spec.controller.podTemplate.spec.containers[0].resources.limits.cpu - it: "linstor-controller liveness probe relaxes timing but leaves httpGet to the operator" asserts: diff --git a/packages/system/linstor/values.yaml b/packages/system/linstor/values.yaml index 4ee1429ec..a7d2f0698 100644 --- a/packages/system/linstor/values.yaml +++ b/packages/system/linstor/values.yaml @@ -101,16 +101,33 @@ linstorCSI: repository: ghcr.io/cozystack/cozystack/linstor-csi tag: v1.6.0@sha256:ae854423de62e94fb89b59d92c20da8939196e643e83b2d60d9f6915d5b0e55c controller: - # Resource requests for the linstor-controller JVM. Requests (not limits) are - # set on purpose: a CPU request guarantees CPU shares so the JVM can answer its - # GET /health liveness probe under node CPU contention, while omitting limits - # avoids throttling the JVM (CPU limit) or OOM-killing it (memory limit). The - # memory value is a conservative starting estimate for the JVM heap + overhead; - # tune it to observed RSS. + # Resources for the linstor-controller JVM. The CPU request guarantees CPU + # shares so the JVM can answer its GET /health liveness probe under node CPU + # contention, and CPU is still deliberately left unlimited so a GC pause or a + # burst of DRBD events is not throttled. The memory request is a conservative + # starting estimate for the JVM heap + overhead; tune it to observed RSS. + # + # The memory limit is stated rather than omitted, and it has to stay above the + # heap ceiling the image was built with. linstor-server bakes + # `-Xms256M -Xmx8G -XX:+CrashOnOutOfMemoryError` into the generated + # bin/Controller (build.gradle, jvmControllerOpts), nothing in this chart or in + # piraeus-entry.sh overrides it, and a JVM given an explicit -Xmx never consults + # its cgroup. So the process will grow to 8G of heap whatever memory.max says, + # and a ceiling below that turns "the JVM crashes itself on OOM, having said so" + # into "the kernel kills the storage control plane mid-operation". 10Gi is 8G of + # heap plus room for metaspace, code cache, thread stacks and direct buffers. + # + # Leaving it unset is no longer the safer option it once was: cozystack-operator + # maintains a LimitRange in every system namespace defaulting container memory + # (cozystackOperator.systemNamespaceMemoryLimit, 4Gi by default), and a container + # that declares no limit of its own is given that one — half this JVM's own heap + # ceiling. Declaring the limit here is what keeps that default away from it. resources: requests: cpu: 250m memory: 700Mi + limits: + memory: 10Gi # Liveness-probe timing for the linstor-controller container. Only these timing # fields are overridden; the httpGet target (GET /health on the api port) is # supplied by piraeus-operator and intentionally left untouched. Relaxed from