Skip to content

feat(charts): CCP-6557 - run Redis under Sentinel in DEV and PR envs (+ PR-env values fix, exporter pin) - #354

Merged
barrfalk merged 5 commits into
fix/ccp-5828-redis-master-pdbfrom
fix/ccp-6557-redis-sentinel
Dec 1, 2026
Merged

barrfalk merged 5 commits into
fix/ccp-5828-redis-master-pdbfrom
fix/ccp-6557-redis-sentinel

Conversation

@NikhilMM89

@NikhilMM89 NikhilMM89 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #353 — base will retarget to main once that merges. Review that one first.

Also folded in here (was #356, plus one small fix)

Kept in this PR rather than opened separately, to keep the review queue short.

1. PR environments deployed Redis with the base values, not DEV's (was #356).

RELEASE_NAME is ${repo}-redis for every caller - no PR number - so a PR touching charts/redis/ upgrades the one shared DEV release. But pr-open.yml passes no environment (the input is documented "omit for PRs"), so it fell through to the base values, i.e. the TEST profile.

This matters directly for this PR: a PR env would leave sentinel.enabled: false while the app chart's DEV/PR profile points at common-notify-redis:26379, so PR envs could never exercise Sentinel at all. It also already scales DEV from 1 replica to 2 today, against the 40Gi quota reason values-dev.yml gives for pinning it at 1 - and once #353 merges, it hands DEV a PDB that DEV deliberately disables.

PROD and TEST are now named explicitly; everything else (DEV and PRs, which share namespace and release) takes values-dev.yml. Only the PR case changes; verified under bash for all four inputs.

2. The redis-exporter image was on :latest while the Redis image itself is digest-pinned.

The tag had already drifted inside a single release:

redis-master-0     metrics  redis-exporter@sha256:81a8259627e4...
redis-replicas-0   metrics  redis-exporter@sha256:8a6962becf2f...
redis-replicas-1   metrics  redis-exporter@sha256:81a8259627e4...

Pinned to the digest the master runs. Only the metrics sidecar is affected, so the worst case is a stalled scrape, not a Redis outage.

Deliberately NOT folded in

  • TEST Redis PVCs are 1Gi against PROD's 8Gi. volumeClaimTemplates are immutable, so changing it means recreating the StatefulSet - not a small change, and it needs its own window.
  • The Redis NetworkPolicy ingress has ports but no from, so any pod in any namespace can reach 6379 (CCP-5696). Getting the from selectors wrong breaks every client, so it deserves its own review rather than riding along here.

The app work was already done

This ticket was sized partly for "rewire ioredis and BullMQ through Sentinel". That already exists:

  • buildRedisOptions() (redis-connection.ts:29) switches to sentinels + name + sentinelPassword whenever REDIS_SENTINELS is set, and falls back to host/port otherwise.
  • Nothing bypasses it. createQueue, createWorker, createQueueEvents and createRedisClient all call it, and the three direct new Redis(...) sites (webhook-trigger.service.ts, notification-pubsub.service.ts ×2) pass its output.
  • charts/app already emits REDIS_SENTINELS, REDIS_MASTER_NAME and REDIS_SENTINEL_PASSWORD behind if .Values.global.config.redisSentinels.

The only reason none of it was live: nothing ever set redisSentinels. So this PR is a values change.

What changes

DEV and every PR env share one Redis release, and both deploy from charts/app/values.yaml — the chart's own defaults, which .deployer.yml uses when no values file is passed. So redisSentinels goes there, and values-test.yaml / values-prod.yaml set it to "" to stay on the direct connection.

sentinel.quorum goes back to 2. This file had overridden the chart default to 1, which lets a single Sentinel declare a failover alone.

Rendered topology

Env StatefulSets Redis Service
dev common-notify-redis-node (3) common-notify-redis — 6379, 26379
test redis-master (1), redis-replicas (2) redis-master — 6379
prod redis-master (1), redis-replicas (2) redis-master — 6379

And the backend env, rendered per values file:

values.yaml        REDIS_SENTINELS=common-notify-redis:26379  REDIS_MASTER_NAME=mymaster
values-test.yaml   (no REDIS_SENTINELS — REDIS_HOST only)
values-prod.yaml   (no REDIS_SENTINELS — REDIS_HOST only)

This is not a drop-in for test or prod

Enabling Sentinel replaces the master/replicas StatefulSets with a single redis-node StatefulSet on new PVCs (redis-data + sentinel-data), and removes the -redis-master Service.

So the AOF does not carry over. This Redis backs a durable Bull queue — maxmemory-policy noeviction, and values.yml says outright it is "NOT a disposable cache". Cutting over test or prod therefore means draining the queues in a window first, not just flipping a value. DEV losing its queue is acceptable, which is why DEV goes first and why test and prod are explicitly pinned here rather than left to inherit.

The old replica PVCs also carry whenDeleted: Delete, so they go with the old StatefulSet.

Verification

  • vitest run src/config/configuration.spec.ts src/queue/redis-connection.spec.ts → 35 passed
  • Redis chart rendered per environment against upstream redis-25.4.1 (the version PROD runs); results are the table above, parsed from the YAML rather than grepped
  • App chart rendered with each of the three values files; REDIS_SENTINELS appears only in the dev/PR profile
  • REDIS_SENTINEL_PASSWORD reads the same redis-password key REDIS_PASSWORD already requires, and that key exists in common-notify-redis in dev — so no new secret dependency and no CreateContainerConfigError risk
  • sentinel.masterSet default is mymaster, matching the backend's REDIS_MASTER_NAME default

What this does not prove

Failover has since been observed on an isolated throwaway release - see the comment below (master deleted, replica promoted in 3s). What is still unproven is the backend connecting through Sentinel: that needs this on DEV.

Three things to watch on the DEV deploy: all 3 redis-node pods reach 2/2 and Sentinel agrees on a master; the backend connects without AUTH errors in the logs; and the queues drain. Then cordon the master's node and confirm a replica is promoted and the API keeps accepting notifications.

Advances CCP-6557 for DEV. Does not close it — test and prod cutover and the drain test remain.


Thanks for the PR!

Deployments, as required, will be available below:

Please create PRs in draft mode. Mark as ready to enable:

After merge, new images are deployed in:

The backend already supports Sentinel. buildRedisOptions() in
backend/src/queue/redis-connection.ts switches to sentinels + masterName when
REDIS_SENTINELS is set, and nothing bypasses it: createQueue, createWorker,
createQueueEvents and createRedisClient all route through it, and the three
direct `new Redis(...)` sites pass its output. charts/app's backend deployment
already emits REDIS_SENTINELS, REDIS_MASTER_NAME and REDIS_SENTINEL_PASSWORD
behind `if global.config.redisSentinels`. The only reason none of it was live
is that nothing ever set that value.

So this is a values change, not an app change.

DEV and the PR envs share the one Redis release, and both deploy from
charts/app/values.yaml (the chart's own defaults, which .deployer.yml uses when
no values file is passed), so redisSentinels is set there. TEST and PROD set it
to "" in their own files to stay on the direct connection until their cutover.

Also sets sentinel.quorum back to 2. This file had overridden the chart default
to 1, which lets a single Sentinel declare a failover on its own.

Rendered topology, per environment:

  dev   StatefulSet common-notify-redis-node      replicas=3
        Service     common-notify-redis           6379, 26379
  test  StatefulSet common-notify-redis-master    replicas=1
        StatefulSet common-notify-redis-replicas  replicas=2
  prod  (same as test)

NOT A DROP-IN FOR TEST/PROD. Sentinel mode replaces the master/replicas
StatefulSets with a single redis-node StatefulSet on new PVCs, and removes the
-redis-master Service. The AOF does not carry over, and this Redis backs a
durable Bull queue (maxmemory-policy noeviction), so cutting over test or prod
means draining the queues in a window first. DEV losing its queue is
acceptable, which is why it goes first.

Verified: both specs pass (35 tests); app chart renders REDIS_SENTINELS only
for the dev/PR profile; REDIS_SENTINEL_PASSWORD reads the same redis-password
key that REDIS_PASSWORD already requires, and that key exists in the dev secret.
@NikhilMM89

Copy link
Copy Markdown
Collaborator Author

Merge-order constraint found after opening this

PR environments share DEV's single Redis release. Three backends in f6bc3f-dev are currently pointed at the service this change removes:

common-notify-dev-backend   REDIS_HOST=common-notify-redis-master
common-notify-284-backend   REDIS_HOST=common-notify-redis-master
common-notify-345-backend   REDIS_HOST=common-notify-redis-master

common-notify-dev is redeployed by the same merge run, so it picks up REDIS_SENTINELS and is fine. The already-deployed PR envs are not — common-notify-redis-master disappears and their backends lose Redis until each is redeployed.

So on merge:

  1. PR fix(deps): update all dependencies to 0.9.1, 1.65.1, v1.6.0, v1.3.0, 1.22.1 #284 (renovate, still open) needs a redeploy — pushing any commit, or re-running its workflow, is enough.
  2. common-notify-345 looks stranded: PR feat: CCP-6455: CSTAR admin controller #345 is merged, but its release is still in dev. Same class of leftover as fix: CCP-6160 - SonarQube fixes part 3 #312. Probably wants removing rather than redeploying.

Neither blocks this PR, but whoever merges it should expect to poke #284 afterwards. Worth a line in the release notes too, since the same thing will happen to any PR env open at the time.

@NikhilMM89

Copy link
Copy Markdown
Collaborator Author

Failover tested and working

The PR said no failover had been observed. It has now. I deployed an isolated throwaway release (redis-sentinel-trial, 3 nodes) into f6bc3f-dev rather than switching the shared Redis, since that would have broken PR envs 284 and 345 before this merges.

Healthy state — all three Sentinels agreed, with the mymaster set name the backend already defaults to:

name                  mymaster
flags                 master
num-slaves            2
num-other-sentinels   2
quorum                2

Failover — deleted the master pod (node-0):

master before : ...-node-0...
deleting the master pod at 16:23:58
PROMOTED after 3s at 16:24:01
master after  : ...-node-2...

Both surviving Sentinels agreed on node-2 immediately. node-0 then rejoined as a replica:

role:slave
master_host:...-node-2...
master_link_status:up

num-slaves back to 2, so the set fully healed.

Correcting something I noted earlier

I flagged that sentinel.downAfterMilliseconds defaults to 60000 and implied a failover means ~60s of unavailability. The measured promotion was 3s. down-after-milliseconds is the ceiling for a node that stops responding while connections stay open — a hard crash or network partition. A graceful shutdown closes the connection and Sentinel reacts at once.

That matters here because a node drain is a graceful eviction, which is precisely the scenario in this ticket. So the drain case is seconds, and the 60s ceiling only applies to a hard node failure. Still arguably worth lowering to 5–10s for that case, but it is not the blocker I suggested.

Caveat

This proves the Sentinel topology and promotion work on this cluster, with this chart version and image, under OpenShift's SCC. It does not exercise the Notify backend against it — buildRedisOptions() is unit-tested and the env wiring renders correctly, but no app has yet connected through Sentinel. That still needs the DEV deploy.

node-0 also read 0/2 on its readiness probe while already serving and replicating, so expect a brief not-ready window per pod on rollout.

Trial release deleted; nothing left behind in dev.

…inel change

The rationale lives in the PR description instead.

Two pre-existing comments were deleted rather than restored, because this
change makes them false: values-dev.yml said Sentinel was disabled "not
needed with only 1 replica", and the sentinel block in values.yml said
enabling it would break the app and to keep it off.

No change to rendered output - dev/PR still get REDIS_SENTINELS, test and
prod still render none.
The exporter ran on :latest while the Redis image itself is digest-pinned.
The tag had already drifted within a single release - redis-master-0 and
redis-replicas-1 on sha256:81a82596, redis-replicas-0 on sha256:8a6962be.

Pinned to the digest the master runs. Only the metrics sidecar is affected,
so the worst case is a stalled scrape rather than a Redis outage.

Folded in here rather than raised as its own PR, to keep the review queue
short.
… ones

The Redis release name is ${repo}-redis for every caller, so a PR that
touches charts/redis/ upgrades the one shared DEV release. PRs pass no
environment, so that upgrade was falling through to the base values.yml -
the TEST profile - and overwriting DEV's own overrides.

Invert the branch: PROD and TEST are named explicitly, everything else
(DEV and PRs, which share the namespace and the release) takes
values-dev.yml.

Today this silently scales DEV's Redis from 1 replica to 2, against the
storage-quota reason values-dev.yml gives for pinning it at 1. It gets
worse with two PRs in flight: #353 adds a master PDB to the base values
that DEV deliberately disables, and #354 enables Sentinel for DEV only,
which a PR deploy would then fail to enable while the app expects it.
@NikhilMM89 NikhilMM89 changed the title feat(charts): CCP-6557 - run Redis under Sentinel in DEV and PR envs feat(charts): CCP-6557 - run Redis under Sentinel in DEV and PR envs (+ PR-env values fix, exporter pin) Dec 1, 2026
sentinel.image set only registry, so it inherited the chart default
bitnami/redis-sentinel:latest - the last floating tag in the release.
That tag was rebuilt on 2026-11-29, which is the same drift that put
three pods in one release on two different exporter builds.

Pinned to the digest whose APP_VERSION is 8.10.3, matching the Redis
image pin, so Sentinel and Redis cannot diverge in version.

Verified with helm template against bitnami/redis 25.4.1: DEV, TEST and
PROD now render every image by digest and no floating tags remain.
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@barrfalk
barrfalk merged commit c7089c0 into fix/ccp-5828-redis-master-pdb Dec 1, 2026
24 checks passed
@barrfalk
barrfalk deleted the fix/ccp-6557-redis-sentinel branch December 1, 2026 22:52
barrfalk pushed a commit that referenced this pull request Dec 2, 2026
* fix(charts): CCP-5828 - stop the Redis master PDB permitting its own eviction

The bitnami chart leaves master.pdb.minAvailable and maxUnavailable empty,
which renders maxUnavailable: 1. Against a single-pod master StatefulSet that
allows one voluntary disruption, so the PDB permits exactly the eviction it
exists to prevent. Verified in PROD:

  common-notify-redis-master     maxUnavailable=1  allowed-disruptions=1

A node drain, cluster upgrade or rebalance can therefore evict the only Redis
master. Nothing promotes a replica (Sentinel has never run, CCP-6557) and the
backend is pinned to REDIS_HOST=common-notify-redis-master, so the Bull queues
stop until the master is rescheduled.

minAvailable: 1 takes allowed-disruptions to 0, so the drain blocks instead.

TRADE-OFF: this does not add failover, it changes the failure mode. A drain of
the master's node will now stall rather than cause a silent prod outage. That
is the safer of the two until Sentinel lands, because a blocked drain is
visible and asks a question, where an evicted master just stops the queues.
It does mean the platform team may hit a stuck drain, so CCP-6557 should not
sit indefinitely behind this.

Replica PDB deliberately unchanged: maxUnavailable: 1 across 2 replicas still
leaves one serving.

Rendered against charts/redis/values.yml with the upstream chart at the version
PROD runs (redis-25.4.1): master PDB becomes minAvailable: 1 with the same
selector as the live object, replica PDB unchanged, all 15 resources render.

* fix(charts): CCP-5828 - repair the dead PDB override in dev

values-dev.yml set master.podDisruptionBudget.enabled and
replica.podDisruptionBudget.enabled. Upstream renamed those to pdb.create, so
both keys were inert and dev has carried PDBs for 101 days despite the comment
saying they were disabled:

  f6bc3f-dev  common-notify-redis-master    maxUnavailable=1  (101d)
  f6bc3f-dev  common-notify-redis-replicas  maxUnavailable=1  (101d)

Switched to pdb.create: false, which honours the original intent and keeps
minAvailable: 1 out of dev. Dev nodes are drained routinely and a blocked
drain there costs more than a Redis restart does.

values.yml is the shared base and TEST gets no override file at all
(.deployer.yml only passes one for DEV and PROD), so the base change lands in
TEST and PROD. Rendered per environment:

  dev   0 PDBs
  test  master minAvailable: 1, replica maxUnavailable: 1
  prod  master minAvailable: 1, replica maxUnavailable: 1

* feat(charts): CCP-6557 - run Redis under Sentinel in DEV and PR envs (+ PR-env values fix, exporter pin) (#354)

* feat(charts): CCP-6557 - run Redis under Sentinel in DEV and PR envs

The backend already supports Sentinel. buildRedisOptions() in
backend/src/queue/redis-connection.ts switches to sentinels + masterName when
REDIS_SENTINELS is set, and nothing bypasses it: createQueue, createWorker,
createQueueEvents and createRedisClient all route through it, and the three
direct `new Redis(...)` sites pass its output. charts/app's backend deployment
already emits REDIS_SENTINELS, REDIS_MASTER_NAME and REDIS_SENTINEL_PASSWORD
behind `if global.config.redisSentinels`. The only reason none of it was live
is that nothing ever set that value.

So this is a values change, not an app change.

DEV and the PR envs share the one Redis release, and both deploy from
charts/app/values.yaml (the chart's own defaults, which .deployer.yml uses when
no values file is passed), so redisSentinels is set there. TEST and PROD set it
to "" in their own files to stay on the direct connection until their cutover.

Also sets sentinel.quorum back to 2. This file had overridden the chart default
to 1, which lets a single Sentinel declare a failover on its own.

Rendered topology, per environment:

  dev   StatefulSet common-notify-redis-node      replicas=3
        Service     common-notify-redis           6379, 26379
  test  StatefulSet common-notify-redis-master    replicas=1
        StatefulSet common-notify-redis-replicas  replicas=2
  prod  (same as test)

NOT A DROP-IN FOR TEST/PROD. Sentinel mode replaces the master/replicas
StatefulSets with a single redis-node StatefulSet on new PVCs, and removes the
-redis-master Service. The AOF does not carry over, and this Redis backs a
durable Bull queue (maxmemory-policy noeviction), so cutting over test or prod
means draining the queues in a window first. DEV losing its queue is
acceptable, which is why it goes first.

Verified: both specs pass (35 tests); app chart renders REDIS_SENTINELS only
for the dev/PR profile; REDIS_SENTINEL_PASSWORD reads the same redis-password
key that REDIS_PASSWORD already requires, and that key exists in the dev secret.

* refactor(charts): CCP-6557 - drop the inline commentary from the Sentinel change

The rationale lives in the PR description instead.

Two pre-existing comments were deleted rather than restored, because this
change makes them false: values-dev.yml said Sentinel was disabled "not
needed with only 1 replica", and the sentinel block in values.yml said
enabling it would break the app and to keep it off.

No change to rendered output - dev/PR still get REDIS_SENTINELS, test and
prod still render none.

* fix(charts): CCP-6557 - pin the redis-exporter image by digest

The exporter ran on :latest while the Redis image itself is digest-pinned.
The tag had already drifted within a single release - redis-master-0 and
redis-replicas-1 on sha256:81a82596, redis-replicas-0 on sha256:8a6962be.

Pinned to the digest the master runs. Only the metrics sidecar is affected,
so the worst case is a stalled scrape rather than a Redis outage.

Folded in here rather than raised as its own PR, to keep the review queue
short.

* fix(ci): CCP-6557 - deploy PR Redis with the DEV values, not the base ones

The Redis release name is ${repo}-redis for every caller, so a PR that
touches charts/redis/ upgrades the one shared DEV release. PRs pass no
environment, so that upgrade was falling through to the base values.yml -
the TEST profile - and overwriting DEV's own overrides.

Invert the branch: PROD and TEST are named explicitly, everything else
(DEV and PRs, which share the namespace and the release) takes
values-dev.yml.

Today this silently scales DEV's Redis from 1 replica to 2, against the
storage-quota reason values-dev.yml gives for pinning it at 1. It gets
worse with two PRs in flight: #353 adds a master PDB to the base values
that DEV deliberately disables, and #354 enables Sentinel for DEV only,
which a PR deploy would then fail to enable while the app expects it.

* fix(charts): CCP-6557 - pin the sentinel image by digest

sentinel.image set only registry, so it inherited the chart default
bitnami/redis-sentinel:latest - the last floating tag in the release.
That tag was rebuilt on 2026-11-29, which is the same drift that put
three pods in one release on two different exporter builds.

Pinned to the digest whose APP_VERSION is 8.10.3, matching the Redis
image pin, so Sentinel and Redis cannot diverge in version.

Verified with helm template against bitnami/redis 25.4.1: DEV, TEST and
PROD now render every image by digest and no floating tags remain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants