Skip to content

Commit ca452a4

Browse files
committed
Wait for failover to complete
1 parent b4d18d3 commit ca452a4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/controller/scripts/pre_stop.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ echo "Pause writes"
2929
valkey-cli -c CLIENT PAUSE "5000" WRITE
3030

3131
valkey-cli -h "${SLAVE_IP}" -p "${SLAVE_PORT}" -c cluster failover
32-
sleep 3s
32+
33+
check_failover_complete() {
34+
ROLE=$(valkey-cli -h "${SLAVE_IP}" -p "${SLAVE_PORT}" INFO REPLICATION | grep role | cut -d':' -f2 | tr -d '\r')
35+
if [ "${ROLE}" = "master" ]; then
36+
return 0
37+
else
38+
return 1
39+
fi
40+
}
41+
42+
echo "Waiting for failover to complete..."
43+
while ! check_failover_complete; do
44+
echo "Failover in progress, waiting..."
45+
sleep 1
46+
done

0 commit comments

Comments
 (0)