Skip to content

Commit b583009

Browse files
docs(operator): document a zero default memory request
--system-namespace-memory-request=0 passes the startup check, since 0 is not greater than the limit, and produces a LimitRange with defaultRequest: 0. Whether that is a footgun to reject or a supported setting to explain was open, so I asked a real API server: envtest with kube-apiserver 1.36.0 and LimitRanger enabled, with a second namespace using 32Mi as the positive control that the plugin was actually running. It is supported. The API server accepts the LimitRange and stores defaultRequest as 0 rather than folding it back to the default -- the Default-to-DefaultRequest copy only fills keys that are absent, and this one is present. A container declaring no memory of its own is then admitted with an explicit request of 0 and a limit of 4Gi, QoS Burstable. So LimitRanger does not read zero as absent, and the container still gets memory.max on its cgroup, which is the whole reason this feature exists. What it costs is the scheduling signal: nothing is reserved for that container, which is exactly where system components stood before this feature. Say so in the flag help text, where an operator setting the knob will see it, and note at the startup check that 0 passing is deliberate so nobody hardens it into a rejection later. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 3ccd9a1 commit b583009

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎cmd/cozystack-operator/main.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ func main() {
157157
flag.StringVar(&systemNamespaceMemoryRequest, "system-namespace-memory-request", "32Mi",
158158
"Default container memory request paired with --system-namespace-memory-limit. Set small and "+
159159
"explicitly: Kubernetes defaults an unset request to the limit, which would reserve the full "+
160-
"limit for every system container at schedule time.")
160+
"limit for every system container at schedule time. 0 is supported and means the opposite "+
161+
"trade rather than a broken value: the API server accepts a LimitRange with defaultRequest 0, "+
162+
"and a container with no memory request of its own is then admitted with an explicit request "+
163+
"of 0 and the default limit, so it still gets the memory.max this feature exists to give it, "+
164+
"while the scheduler reserves nothing for it - the same scheduling signal system components "+
165+
"had before this feature, no worse and no better.")
161166

162167
opts := zap.Options{
163168
Development: true,
@@ -202,7 +207,8 @@ func main() {
202207
systemNSMemoryLimit := parseQuantity("--system-namespace-memory-limit", systemNamespaceMemoryLimit)
203208
systemNSMemoryRequest := parseQuantity("--system-namespace-memory-request", systemNamespaceMemoryRequest)
204209
// A LimitRange whose defaultRequest exceeds its default is rejected by the API server,
205-
// which would wedge namespace reconciliation for every system package.
210+
// which would wedge namespace reconciliation for every system package. A request of 0
211+
// passes this check deliberately; see the flag's help text for what it trades away.
206212
if !systemNSMemoryLimit.IsZero() && systemNSMemoryRequest.Cmp(systemNSMemoryLimit) > 0 {
207213
setupLog.Error(fmt.Errorf("--system-namespace-memory-request must not exceed --system-namespace-memory-limit"),
208214
"invalid value", "request", systemNamespaceMemoryRequest, "limit", systemNamespaceMemoryLimit)

0 commit comments

Comments
 (0)