fup
This commit is contained in:
@ -15,7 +15,8 @@ pingSentinel() {
|
||||
}
|
||||
|
||||
getPrimaryInfo() {
|
||||
valkey-cli --csv -h ${VALKEY_HEADLESS_SERVICE} -p ${VALKEY_SENTINEL_PORT} sentinel get-primary-addr-by-name "mymaster"| \
|
||||
VALKEY_MASTER_NAME=${VALKEY_PRIMARY_NAME:-"mymaster"}
|
||||
valkey-cli --csv -h ${VALKEY_HEADLESS_SERVICE} -p ${VALKEY_SENTINEL_PORT} sentinel get-primary-addr-by-name "${VALKEY_MASTER_NAME}"| \
|
||||
awk -F ',' '{ gsub(/"/,"",$0); print $1 " " $2 }'
|
||||
return ${?}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ vcli-sentinel() {
|
||||
getFailOverStatus() {
|
||||
# Check if the failover is finished
|
||||
local failoverStatus
|
||||
primaryInfo=$(vcli-sentinel get-primary-addr-by-name "mymaster")
|
||||
sentinelMasterName="${VALKEY_MASTER_NAME:-"mymaster"}"
|
||||
primaryInfo=$(vcli-sentinel get-primary-addr-by-name "${sentinelMasterName}")
|
||||
primaryHost=$(echo ${primaryInfo} | awk -F ' ' '{print $1}')
|
||||
currentHost=$(hostname -f)
|
||||
if [[ "${primaryHost}" != "${currentHost}" ]]; then
|
||||
@ -44,12 +45,13 @@ isPrimary() {
|
||||
}
|
||||
|
||||
if isPrimary && ! getFailOverStatus; then
|
||||
sentinelMasterName="${VALKEY_MASTER_NAME}"
|
||||
echo "I'm the primary and you are stopping me, pausing client connections"
|
||||
#Pausing write connections to avoid data loss"
|
||||
vcli CLIENT PAUSE "22000" WRITE
|
||||
|
||||
echo "Starting failover"
|
||||
vcli-sentinel failover "mymaster"
|
||||
vcli-sentinel failover "${sentinelMasterName}"
|
||||
echo "Waiting for sentinel to complete failover for up to 120s"
|
||||
tmout=120
|
||||
while true ; do
|
||||
|
@ -12,7 +12,8 @@ pingSentinel() {
|
||||
}
|
||||
|
||||
getPrimaryInfo() {
|
||||
valkey-cli -t 15 --csv -h ${VALKEY_HEADLESS_SERVICE} -p ${VALKEY_SENTINEL_PORT} sentinel get-primary-addr-by-name "mymaster"| \
|
||||
sentinelMasterName="${VALKEY_PRIMARY_NAME:-"mymaster"}"
|
||||
valkey-cli -t 15 --csv -h ${VALKEY_HEADLESS_SERVICE} -p ${VALKEY_SENTINEL_PORT} sentinel get-primary-addr-by-name "${sentinelMasterName}"| \
|
||||
awk -F ',' '{ gsub(/"/,"",$0); print $1 " " $2 }'
|
||||
return ${?}
|
||||
}
|
||||
|
Reference in New Issue
Block a user