docs(tenant): qualify LimitRange defaults by the bounded resource

tenant-range-limits now defaults cpu, memory and ephemeral-storage
each only when resourceQuotas bounds that resource, and is not
rendered at all under a quota on none of them. Comments in the
operator, the tenant quota controller, the backup controller and the
barman and kafka charts still said every tenant with resourceQuotas
gets a 128Mi memory default, which would mislead the next change made
on that assumption.

The tenant quota controller's gate on limits.cpu or limits.memory
stays: a root rendered by an older chart may still carry a LimitRange
under a quota that bounds no compute.

Assisted-by: LLM
Signed-off-by: Nimesh Kulkarni <167794819+GitNimay@users.noreply.github.com>
(cherry picked from commit 46f03b8748)
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
Nimesh Kulkarni authored and Myasnikov Daniil committed 2026-11-25 10:49:46 +00:00
1 parent 3bda3f4e95
commit 6be80ea299
7 files changed
+32 -26

No files matched your search

@@ -2210,15 +2210,16 @@ func buildBarmanPlugin(objectStoreName, serverName string) cnpgtypes.PluginConfi
// cannot get right on its own.
//
// Resources: the plugin injects the sidecar with no resources. This ObjectStore
// lands in the application's namespace, and a tenant with resourceQuotas set
// carries a LimitRange (packages/apps/tenant/templates/quota.yaml) that defaults
// every container to 128Mi; the sidecar is OOMKilled mid-backup under it,
// leaving the ObjectStore healthy and the backup failed. Measured cgroup
// lands in the application's namespace, and a tenant whose resourceQuotas bound
// memory carries a LimitRange (packages/apps/tenant/templates/quota.yaml) that
// defaults every container to 128Mi; the sidecar is OOMKilled mid-backup under
// it, leaving the ObjectStore healthy and the backup failed. Measured cgroup
// high-water mark on a 38 MB database is 254 MiB, so 128Mi cannot hold it. A
// tenant that leaves resourceQuotas empty has no LimitRange, and there the
// sidecar had no requests and no limit at all. 256Mi holds the measured working
// set and 1Gi is four times the measurement. The CPU limit is explicit for the
// same reason: left unset, that LimitRange gives the sidecar its 250m default,
// tenant whose resourceQuotas bound none of cpu, memory or ephemeral-storage has
// no LimitRange, and there the sidecar had no requests and no limit at all.
// 256Mi holds the measured working set and 1Gi is four times the measurement.
// The CPU limit is explicit for the same reason: left unset, a LimitRange under
// a cpu quota gives the sidecar its 250m default,
// so gzip compression of full backups and WAL segments runs on a quarter of a
// core (a 1.6 GB database took 30 minutes to back up). One core keeps the
// sidecar from starving the instance while removing that ceiling; it counts
@@ -354,10 +354,11 @@ func ownedNamespace(hrNamespace, appName string) string {
// boundsComputeLimits reports whether a quota bounds limits.cpu or
// limits.memory, the only case in which admission rejects a container that
// omits a limit. The chart renders its LimitRange under any non-empty
// resourceQuotas, so the root may carry one under a quota that bounds no
// compute at all; copying it then would impose default limits the quota
// never asked for.
// omits a limit. The chart's LimitRange defaults only the resources the root's
// quota bounds, but a root created by an older chart may still carry one
// rendered under any non-empty resourceQuotas, compute or not; copying it to a
// member whose quota bounds no compute limit would impose default limits the
// quota never asked for.
func boundsComputeLimits(hard corev1.ResourceList) bool {
_, cpu := hard[corev1.ResourceLimitsCPU]
_, memory := hard[corev1.ResourceLimitsMemory]
@@ -364,8 +364,9 @@ func TestReconcile_PoolRootWithoutLimitRange(t *testing.T) {
}
}
// TestReconcile_NoLimitRangeWithoutComputeLimitQuota: the chart renders its
// LimitRange for any non-empty resourceQuotas, compute or not. A member whose
// TestReconcile_NoLimitRangeWithoutComputeLimitQuota: a chart release older
// than the per-resource defaults renders its LimitRange for any non-empty
// resourceQuotas, compute or not, and the root may still carry it. A member whose
// allocated quota bounds neither limits.cpu nor limits.memory is admitted
// without limits today; copying the root's defaults there would cap or refuse
// pods (one requesting more than the default memory limit, for instance)
+2 -1
View File
@@ -950,7 +950,8 @@ func (r *PackageReconciler) deleteManagedSystemDefaultsLimitRanges(ctx context.C
// Defaulting a limit across system namespaces takes those components out of the candidate
// set. Tenant namespaces are skipped because the tenant chart owns LimitRange policy
// there: packages/apps/tenant ships tenant-range-limits, which defaults container memory
// to 128Mi in every tenant namespace that declares resourceQuotas. Handing a second,
// to 128Mi in every tenant namespace whose resourceQuotas bound memory (and cpu or
// ephemeral-storage likewise, each only when the quota bounds it). Handing a second,
// system-owned LimitRange to those namespaces would layer a competing default on top of
// the chart's own, so the operator stays out.
//
+1 -1
View File
@@ -923,7 +923,7 @@ func TestReconcileSystemDefaultsLimitRangeForcesOnlyAnOwnedObject(t *testing.T)
// The tenant boundary. It is one strings.HasPrefix, and everything downstream of it depends
// on it holding: packages/apps/tenant ships tenant-range-limits, which defaults container
// memory to 128Mi in every tenant namespace with resourceQuotas. A system LimitRange landing
// memory to 128Mi in every tenant namespace whose resourceQuotas bound memory. A system LimitRange landing
// beside it would leave two LimitRanges defaulting the same containers, and which one wins
// is decided by the order LimitRanger happens to iterate them — neither chart controls that,
// so a tenant container's default memory limit would move between 128Mi and 4Gi with nothing
+2 -1
View File
@@ -72,7 +72,8 @@ spec:
name: {{ .Release.Name }}-metrics
key: kafka-metrics-config.yml
entityOperator:
# Tenant namespaces ship a LimitRange that defaults containers to 128Mi.
# Tenant namespaces whose quota bounds memory ship a LimitRange that
# defaults containers to 128Mi.
# The topic-operator and user-operator are JVM processes and OOMKill at
# that default, leaving the entity-operator in CrashLoopBackOff so
# KafkaTopics/KafkaUsers never reconcile. Set explicit resources so they
@@ -4,17 +4,18 @@ cozy-lib.barman.sidecarConfiguration renders a barman-cloud ObjectStore
plugin. It carries the two settings the sidecar cannot get right on its own.
Resources: the plugin injects the sidecar with no resources, and what that
means depends on the namespace. A tenant with resourceQuotas set carries a
LimitRange (packages/apps/tenant/templates/quota.yaml) that defaults every
container to 128Mi; the sidecar is OOMKilled mid-backup under it, leaving the
ObjectStore healthy and the backup failed. Measured cgroup high-water mark on a
38 MB database is 254 MiB, so 128Mi cannot hold it. A namespace without a
LimitRange, which is cozy-keycloak and any tenant that leaves resourceQuotas
empty, gave the sidecar no requests and no limit at all, so nothing reserved
means depends on the namespace. A tenant whose resourceQuotas bound memory
carries a LimitRange (packages/apps/tenant/templates/quota.yaml) that defaults
every container to 128Mi; the sidecar is OOMKilled mid-backup under it, leaving
the ObjectStore healthy and the backup failed. Measured cgroup high-water mark
on a 38 MB database is 254 MiB, so 128Mi cannot hold it. A namespace without a
LimitRange, which is cozy-keycloak and any tenant whose resourceQuotas bound
none of cpu, memory or ephemeral-storage, gave the sidecar no requests and no
limit at all, so nothing reserved
memory for it and nothing bounded it. The same request and limit settle both:
256Mi holds the measured working set and 1Gi is four times the measurement.
The CPU limit is explicit for the same reason: left unset, that LimitRange
gives the sidecar its 250m default, so gzip compression of full backups and
The CPU limit is explicit for the same reason: left unset, a LimitRange under
a cpu quota gives the sidecar its 250m default, so gzip compression of full backups and
WAL segments runs on a quarter of a core (a 1.6 GB database took 30 minutes
to back up). One core keeps the sidecar from starving the instance while
removing that ceiling. Inside a tenant both limits count against the