Skip to content

feat: add preStop lifecycle hook for replication mode#1694

Open
peins94 wants to merge 2 commits intoOT-CONTAINER-KIT:mainfrom
peins94:feat/replication-prestop-hook
Open

feat: add preStop lifecycle hook for replication mode#1694
peins94 wants to merge 2 commits intoOT-CONTAINER-KIT:mainfrom
peins94:feat/replication-prestop-hook

Conversation

@peins94
Copy link
Copy Markdown

@peins94 peins94 commented Feb 27, 2026

Description

Replication mode pods currently have no preStop lifecycle hook, unlike cluster mode.
When a master pod is terminated during a rolling update or node drain, clients experience
downtime until Sentinel detects the failure and triggers a failover (up to down-after-milliseconds).
This adds a preStop hook for the replication role following the same pattern as the existing
cluster mode hook in generateClusterPreStop. The hook:

  1. Checks if the terminating pod is the master via INFO replication
  2. Derives the Sentinel headless service from the pod hostname
  3. Triggers SENTINEL FAILOVER mymaster
  4. Waits up to 30 seconds for the role to change to slave
    Replica pods skip the hook entirely.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Tests have been added/modified and all tests pass.
  • Functionality/bugs have been confirmed to be unchanged or fixed.
  • I have performed a self-review of my own code.
  • Documentation has been updated or added where necessary.

Additional Context

In production we observed that every rolling restart of a RedisReplication StatefulSet causes
client downtime because the master pod is killed without failover. This is particularly
impactful for large datasets where replica startup takes 30-40 minutes, as Sentinel may
trigger unnecessary full resyncs while the topology is unstable.

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.

1 participant