Aleksei Sviridkin 79ed8e1164 fix(redis): let the operator delete a disabled Sentinel PDB instead of a per-upgrade hook (#5429)
## 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 -->
2026-12-02 12:46:07 +03:00
2026-11-04 00:56:56 +01:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

GitHub Release Apache-2.0 License Commit activity OpenSSF Best Practices OpenSSF Scorecard CLOMonitor Support

Cozystack

Cozystack is a free and open-source platform and framework for building clouds.

Cozystack is a CNCF Sandbox project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You are welcome to take on the fix yourself. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join us in #cozystack, on either CNCF Slack (get an invite) or Kubernetes Slack (get an invite), in our Telegram group, and at our community meetings. Add them to your Google Calendar or iCal for convenience.

Project documents

Document What it covers
Governance How decisions are made and who makes them
Contributor Ladder How to grow from contributor to maintainer
Maintainers Who maintains the project
Code of Conduct What we expect of each other
Security Policy Reporting a vulnerability, and which releases get fixes
Adopters Who runs Cozystack in production
Roadmap Where the project is going

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 53.3%
Shell 33.1%
TypeScript 6.6%
Go Template 4.7%
Makefile 1.2%
Other 1%