mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
## What this PR does Lets a tenant run Redis as a pure cache without giving up the persistent volume. Until now the chart only turned snapshots off together with the volume (when `size` is empty), and offered no way to bound memory: a `CONFIG SET maxmemory` is lost when the pod restarts. On a cache-only instance, RDB snapshots and replica full syncs then filled the volume, and each SIGKILL during a save left an orphaned `temp-*.rdb` behind, so the instance crashlooped. New values: - `maxmemory` (quantity, unset by default): rendered in bytes. Unset renders `maxmemory 0`, the Redis default (no limit). - `maxmemoryPolicy` (enum, default `noeviction`): rendered as `maxmemory-policy`. - `snapshots` (bool, default `true`): `false` renders `save ""` while keeping the volume. Snapshots stay off when `size` is empty, as before. Every directive is rendered with an explicit value, defaults included. The operator applies `customConfig` with `CONFIG SET` on every reconcile and never resets a directive whose line disappears (`service/redis/client.go` in freshworks-oss/redis-operator v3.3.5), so leaving the defaults implicit would turn reverting a setting into a no-op until the next pod restart. As a consequence, existing instances gain `save 3600 1 300 100 60 10000`, `maxmemory 0` and `maxmemory-policy noeviction` on upgrade. These equal the Redis 7 and 8 defaults, but they overwrite any value an operator set by hand with `CONFIG SET`. `maxmemory` is refused at render time above 90% of the Redis memory request: above that threshold (`reservedPodMemoryPercent`, default 10) the operator logs an error and skips the line, which would leave Redis unbounded with nothing visible to the tenant. Not changed here: a replica still writes a temporary RDB to disk during a full sync (`repl-diskless-load` defaults to `disabled`), even with `snapshots: false`. `stop-writes-on-bgsave-error` keeps its default, since no background save runs once snapshots are off. Tests: `tests/cache_config_test.yaml` covers the rendered defaults, the snapshot toggle with and without a volume, byte conversion from presets and explicit resources, and both refusals. `helm unittest packages/apps/redis` passes (93 tests). ### Screenshots Not a UI change. ### Downstream repositories The new fields in `values.schema.json` reach `cozystack/terraform-provider-cozystack`, whose redis schema and expand/flatten pair are hand-written; no follow-up has been opened there yet, so the box is left unticked. The website reference page is regenerated from `README.md` by the release bot. - [ ] 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 feat(redis): add `maxmemory`, `maxmemoryPolicy` and `snapshots` values so Redis can run as a pure cache (bounded memory, eviction, no RDB snapshots) while keeping its persistent volume. Existing instances now render the Redis defaults for these directives explicitly, which resets any value set by hand with `CONFIG SET`. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added configurable Redis memory limits, with a default of unlimited, and eviction policies, defaulting to `noeviction`. Configured limits must be whole-byte quantities and cannot exceed 90% of the pod’s memory request. * Added controls for scheduled Redis snapshots. Snapshots are enabled by default when storage is configured; disabling them does not remove existing snapshot files, and snapshots are off when storage size is empty. * **Documentation** * Documented the new Redis memory and snapshot settings, including defaults, constraints, and effects. <!-- 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