Watch
0
0
Fork
You've already forked hyperhive
0

k8s: a pod's requests are explicit, so its limits cap and reserve nothing

This commit is contained in:
atlas 2026-11-21 23:42:12 +01:00 • committed by maia
commit eda01b8b1d

View file

@ -832,10 +832,11 @@ let
&& lib.hasInfix "swarm-stt.yaml" sttPrune.script;
}
{
# The unit's ceilings are the pod's limits, and the limits the pod has
# no field for are not rendered. The controller's pod, whose unit sets
# none, is the control that nothing is added to a pod without them.
name = "the speech-to-text pod carries its unit's memory and CPU ceilings as limits and no requests, and a pod whose unit sets none carries none";
# The unit's ceilings are the pod's limits and reserve nothing, and the
# limits the pod has no field for are not rendered. The controller's pod,
# whose unit sets none, is the control that nothing is added to a pod
# without them.
name = "the speech-to-text pod carries its unit's memory and CPU ceilings as limits and reserves nothing, and a pod whose unit sets none carries none";
ok =
let
unit = units.swarm-stt.serviceConfig;
@ -849,7 +850,11 @@ let
memory = "3Gi";
cpu = "4000m";
}
&& !((container "swarm-stt").resources ? requests)
&&
(container "swarm-stt").resources.requests == {
memory = "0";
cpu = "0";
}
&& !(lib.hasInfix "TasksMax" rendered)
&& !(lib.hasInfix "SystemCallFilter" rendered)
&& lib.all (name: !((container name) ? resources)) [
@ -898,6 +903,40 @@ let
CPUQuota = "4";
}));
}
{
# `MemoryMin` wins over `MemoryLow`, either is the memory the pod asks
# for, and the cpu request stays 0. A unit with neither is the control.
name = "a unit's MemoryMin, else its MemoryLow, is the pod's memory request, and one the renderer cannot read fails the evaluation";
ok =
let
withSc =
sc: lib.recursiveUpdate allLocal { services.hyperhive.deploy.stt.unit.serviceConfig = sc; };
resourcesOf =
sc: (lib.head (render (withSc sc))."swarm-stt/deployment".spec.template.spec.containers).resources;
in
(resourcesOf { }).requests.memory == "0"
&&
(resourcesOf { MemoryLow = "256M"; }).requests == {
memory = "256Mi";
cpu = "0";
}
&&
(resourcesOf {
MemoryMin = "1G";
MemoryLow = "256M";
}).requests.memory == "1Gi"
&&
(resourcesOf { MemoryLow = "256M"; }).limits == {
memory = "3Gi";
cpu = "4000m";
}
&& !(renders (withSc {
MemoryLow = "10%";
}))
&& !(renders (withSc {
MemoryMin = "infinity";
}));
}
{
name = "the speech-to-text pod has probes on its health listener, keeps its cache in a volume, mounts no Secret, and runs as every pod does";
ok =