mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-05 22:53:43 +09:00
## What this PR does When a Redis instance runs a single pod, the chart runs one Sentinel and sets `disablePodDisruptionBudget` on it. The redis-operator stops ensuring the Sentinel PDB once that flag is set, but never deletes the PDB it created earlier, and the PDB's owner reference only removes it together with the RedisFailover. An instance scaled down from three pods therefore keeps a `minAvailable: 1` PDB on its only Sentinel, and every node drain blocks on it. The chart worked around this with a post-upgrade Helm hook: a ServiceAccount, a Role, a RoleBinding and a kubectl Job, rendered on every upgrade of every single-replica instance, to delete a PDB the operator should have removed itself. The operator image is already built in this repository with carried patches, so I fixed it there instead. - `redis-operator`: a new source patch makes the operator look the Sentinel or Redis PDB up on reconcile while its `disablePodDisruptionBudget` is set, and delete it only when the RedisFailover is its controller. A PDB without that owner is left alone, no delete is sent when there is no PDB, and one that disappears between the lookup and the delete counts as done. It has a unit test next to the operator's own `EnsureSentinelDeployment` tests, which the image build runs for every package a patch touches. The patch header says it is carried until an upstream release includes the change. - `redis`: the hook, its RBAC, its chart tests and the `redis.sentinelReplicas` helper extracted for it are removed. The single-Sentinel change and its tests stay as they were. - e2e: the base Redis case now scales its instance from two replicas to one and asserts that `rfs-<name>` existed before and is gone after, and that the data pods' PDB stays. Upgrade: an instance that still has the stale PDB loses it on the first reconcile by the updated operator, which resyncs every RedisFailover every 30 seconds. Until the operator Deployment rolls, the PDB stays, so drains on such an instance can block for that window. Hook objects from earlier upgrades are not release resources, so Helm does not touch them; the successful runs already deleted theirs through `hook-succeeded`. A run that failed leaves its ServiceAccount, Role and RoleBinding named `<release>-sentinel-pdb` behind (its Job goes after an hour through `ttlSecondsAfterFinished`). They grant only get and delete on one PDB and can be removed by hand. Cost: while a PDB is disabled, every reconcile (on each RedisFailover change and on the 30-second resync) reads it once from the API server; a delete is sent only when an owned PDB is still there. I have not run the image build or the e2e suite. The patch series applies on the v3.3.5 tarball, alone and together with the operator patch of the open draft #5382, and every package it touches passes `go test` and `go vet -tags integration`. `helm unittest packages/apps/redis` passes. Upstream v3.3.5 is the latest release and its master still has the same code, so there is no version to bump to; a version of the patch rebased onto upstream master, without the `tlsHash` parameter the carried TLS patch adds, is open as freshworks-oss/redis-operator#93, and the patch header links to it. ### Screenshots Not a UI change. ### Downstream repositories - [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: No values key, schema, README or version enum changes; the diff touches an image patch, chart templates and tests, and the Redis e2e suite only. ### Release note ```release-note fix(redis): the redis-operator now deletes the Sentinel or Redis PodDisruptionBudget it created once that budget is disabled, so a Redis scaled down to one replica no longer keeps the Sentinel PDB that blocks node drains, and the chart no longer runs a cleanup Job with its own RBAC on every upgrade of a single-replica instance. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Redis and Sentinel PodDisruptionBudgets are removed when their respective settings disable management, provided they are owned by the RedisFailover. Missing or unrelated budgets are left unchanged. * Sentinel replica counts remain at one when Redis is configured with one replica, and three otherwise. * When switching to one Sentinel replica with PDB management disabled, the Sentinel budget is removed while the data-pod budget remains. The Helm release is then verified as ready. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd