Skip to content

Commit 0bd6ae0

Browse files
committed
fix(backups): give the sidecar sizing its reason per caller
The Keycloak comment and the helper doc claimed the tenant LimitRange as the reason for the resources, but cozy-keycloak has no LimitRange and neither does a tenant that leaves resourceQuotas empty: there the sidecar had no requests and no limit at all, and the change gives it a 1Gi ceiling where there was none. The comments and both doc blocks now say what applies to each caller. No rendered object changes. Assisted-by: LLM Signed-off-by: Yan Bondarenko <[email protected]>
1 parent 24828b3 commit 0bd6ae0

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

‎internal/backupcontroller/cnpgstrategy_controller.go‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,14 +1668,17 @@ func buildBarmanPlugin(objectStoreName, serverName string) cnpgtypes.PluginConfi
16681668
// barmanSidecarConfiguration carries the two settings the barman-cloud sidecar
16691669
// cannot get right on its own.
16701670
//
1671-
// Resources: tenant namespaces ship a LimitRange defaulting containers to 128Mi
1672-
// (packages/apps/tenant/templates/quota.yaml). The plugin injects the sidecar
1673-
// without resources, so it inherits that default and is OOMKilled mid-backup,
1671+
// Resources: the plugin injects the sidecar with no resources. This ObjectStore
1672+
// lands in the application's namespace, and a tenant with resourceQuotas set
1673+
// carries a LimitRange (packages/apps/tenant/templates/quota.yaml) that defaults
1674+
// every container to 128Mi; the sidecar is OOMKilled mid-backup under it,
16741675
// leaving the ObjectStore healthy and the backup failed. Measured cgroup
1675-
// high-water mark on a 38 MB database is 254 MiB, so 128Mi cannot hold it. No
1676-
// CPU limit is set, matching the entityOperator precedent in
1677-
// packages/apps/kafka: a throttled sidecar stalls WAL archiving instead of
1678-
// failing it.
1676+
// high-water mark on a 38 MB database is 254 MiB, so 128Mi cannot hold it. A
1677+
// tenant that leaves resourceQuotas empty has no LimitRange, and there the
1678+
// sidecar had no requests and no limit at all. 256Mi holds the measured working
1679+
// set and 1Gi is four times the measurement. No CPU limit is set, matching the
1680+
// entityOperator precedent in packages/apps/kafka: a throttled sidecar stalls
1681+
// WAL archiving instead of failing it.
16791682
//
16801683
// Checksum: since botocore ~1.36 the default (when_supported) attaches a
16811684
// flexible checksum to every PutObject, which non-AWS S3-compatible backends

‎packages/apps/postgres/templates/db.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ spec:
329329
{{- if .Values.backup.retentionPolicy }}
330330
retentionPolicy: {{ .Values.backup.retentionPolicy | quote }}
331331
{{- end }}
332-
# Size the barman-cloud sidecar off the tenant LimitRange default and pin its
333-
# S3 request checksum (rationale in cozy-lib.barman.sidecarConfiguration).
332+
# Size the barman-cloud sidecar explicitly instead of inheriting the tenant
333+
# LimitRange default of 128Mi, and pin its S3 request checksum (rationale in
334+
# cozy-lib.barman.sidecarConfiguration).
334335
{{- include "cozy-lib.barman.sidecarConfiguration" . | nindent 2 }}
335336
configuration:
336337
destinationPath: {{ $destinationPath }}

‎packages/library/cozy-lib/templates/_barman.tpl‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ cozy-lib.barman.sidecarConfiguration renders a barman-cloud ObjectStore
33
`spec.instanceSidecarConfiguration` shared by every chart that enables the
44
plugin. It carries the two settings the sidecar cannot get right on its own.
55
6-
Resources: tenant namespaces ship a LimitRange defaulting containers to 128Mi
7-
(packages/apps/tenant/templates/quota.yaml). The plugin injects the sidecar
8-
without resources, so it inherits that default and is OOMKilled mid-backup,
9-
leaving the ObjectStore healthy and the backup failed. Measured cgroup
10-
high-water mark on a 38 MB database is 254 MiB, so 128Mi cannot hold it. No CPU
11-
limit is set, matching the entityOperator precedent in packages/apps/kafka: a
12-
throttled sidecar stalls WAL archiving instead of failing it.
6+
Resources: the plugin injects the sidecar with no resources, and what that
7+
means depends on the namespace. A tenant with resourceQuotas set carries a
8+
LimitRange (packages/apps/tenant/templates/quota.yaml) that defaults every
9+
container to 128Mi; the sidecar is OOMKilled mid-backup under it, leaving the
10+
ObjectStore healthy and the backup failed. Measured cgroup high-water mark on a
11+
38 MB database is 254 MiB, so 128Mi cannot hold it. A namespace without a
12+
LimitRange, which is cozy-keycloak and any tenant that leaves resourceQuotas
13+
empty, gave the sidecar no requests and no limit at all, so nothing reserved
14+
memory for it and nothing bounded it. The same request and limit settle both:
15+
256Mi holds the measured working set and 1Gi is four times the measurement.
16+
No CPU limit is set, matching the entityOperator precedent in
17+
packages/apps/kafka: a throttled sidecar stalls WAL archiving instead of
18+
failing it. Inside a tenant the limit counts against the ResourceQuota
19+
limits.memory budget, 1Gi per instance pod.
1320
1421
Checksum: since botocore ~1.36 (early 2025) the default
1522
RequestChecksumCalculation is when_supported, which attaches a flexible checksum

‎packages/system/keycloak/templates/db.yaml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ spec:
5151
{{- if .Values.backup.retentionPolicy }}
5252
retentionPolicy: {{ .Values.backup.retentionPolicy | quote }}
5353
{{- end }}
54-
# Size the barman-cloud sidecar off the tenant LimitRange default and pin its
55-
# S3 request checksum (rationale in cozy-lib.barman.sidecarConfiguration).
54+
# Give the barman-cloud sidecar explicit resources: cozy-keycloak has no
55+
# LimitRange, so the plugin's default was no requests and no limit at all.
56+
# The sizing and the S3 request checksum pin are explained in
57+
# cozy-lib.barman.sidecarConfiguration.
5658
{{- include "cozy-lib.barman.sidecarConfiguration" . | nindent 2 }}
5759
configuration:
5860
destinationPath: {{ .Values.backup.destinationPath | quote }}

0 commit comments

Comments
 (0)