fix(etcd): size the defrag job for the client it runs (#5100)

## What this PR does

The hourly `etcd-defrag` CronJob runs the `ghcr.io/ahrtr/etcd-defrag`
client, which only sends defragment calls to the members, but it
requested 200m CPU and 256Mi from the tenant quota and limited itself at
500m and 512Mi. On a v1.6.5 sandbox tenant created through the panel,
its own etcd and SeaweedFS took 1525m of the 1600m CPU quota, every
hourly job failed with `exceeded quota` before a pod was created, and
the defrag never ran once. Over a day on another v1.6.5 cluster the
client peaked at 5.1 MiB working set, and its runs are too short to show
up in a CPU rate.

The container now requests 10m and 32Mi and is limited at 100m and 64Mi,
so it fits a tight tenant quota and still leaves the client room above
what it was seen to use. The tenant LimitRange only sets defaults, so
explicit small values are not rejected.

A new case in `tests/defrag_test.yaml` pins the resources. `helm
unittest .` in `packages/extra/etcd` passes 26 of 26 with helm-unittest
1.1.2, and against the template on main the new case fails and the other
25 pass. I have not run the change on a live cluster.

The template is the same on release-1.6, and that backport is a separate
PR.

### Screenshots

Not a UI change.

### Downstream repositories

One template of `packages/extra/etcd` and its test. No values key,
schema, default or package change, so no trigger map entry applies.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(etcd): the tenant etcd defrag job requests 10m and 32Mi instead of 200m and 256Mi, so it runs in tenants whose quota is nearly used up by their own services.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Updates**
* The etcd defragmentation job now has lower CPU and memory requests and
limits: requests are 10m CPU and 32Mi memory, and limits are 100m CPU
and 64Mi memory. This reduces the resources configured for the job.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-11-13 15:14:07 +03:00
commit 12393ec3d3
2 files changed
+17 -4

No files matched your search

@@ -29,11 +29,11 @@ spec:
drop: ["ALL"]
resources:
requests:
cpu: 200m
memory: 256Mi
cpu: 10m
memory: 32Mi
limits:
cpu: 500m
memory: 512Mi
cpu: 100m
memory: 64Mi
args:
# The v1alpha2 operator names the headless Service after the
# cluster ({{ $.Release.Name }}) and does not use StatefulSet
@@ -41,3 +41,16 @@ tests:
documentSelector:
path: kind
value: EtcdCluster
- it: asks the tenant quota only for what the defrag client uses
template: templates/etcd-defrag.yaml
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources
value:
requests:
cpu: 10m
memory: 32Mi
limits:
cpu: 100m
memory: 64Mi