Skip to content

Commit 4fc8771

Browse files
committed
fixed reset password
1 parent aabc960 commit 4fc8771

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pkg/redisutil/admin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,14 @@ func (a *Admin) ResetPassword(newPassword string) error {
532532
}
533533
for addr, c := range a.Connections().GetAll() {
534534
a.log.Info("reset password", "addr", addr)
535-
setPasswdResp := c.Cmd("CONFIG", "SET", "requirepass", newPassword)
536-
if err := a.Connections().ValidateResp(setPasswdResp, addr, "cannot set new requirepass"); err != nil {
537-
return err
538-
}
539535
setMasterauth := c.Cmd("CONFIG", "SET", "masterauth", newPassword)
540536
if err := a.Connections().ValidateResp(setMasterauth, addr, "cannot set new masterauth"); err != nil {
541537
return err
542538
}
539+
setPasswdResp := c.Cmd("CONFIG", "SET", "requirepass", newPassword)
540+
if err := a.Connections().ValidateResp(setPasswdResp, addr, "cannot set new requirepass"); err != nil {
541+
return err
542+
}
543543
}
544544
return nil
545545
}

pkg/resources/configmaps/configmap.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ failover() {
2929
echo "Master: ${masterID}"
3030
slave=$(cat ${CLUSTER_CONFIG} | grep ${masterID} | grep "slave" | awk 'NR==1{print $2}' | sed 's/:6379@16379//')
3131
echo "Slave: ${slave}"
32-
redis-cli -h ${slave} -a "${REDIS_PASSWORD}" CLUSTER FAILOVER
33-
echo "Wait for MASTER <-> SLAVE syncFinished"
34-
sleep 20
32+
if [[ -z "${REDIS_PASSWORD}" ]]; then
33+
redis-cli -h ${slave} CLUSTER FAILOVER
34+
else
35+
redis-cli -h ${slave} -a "${REDIS_PASSWORD}" CLUSTER FAILOVER
36+
fi
37+
echo "Wait for MASTER <-> SLAVE syncFinished"
38+
sleep 20
3539
}
3640
if [ -f ${CLUSTER_CONFIG} ]; then
3741
cat ${CLUSTER_CONFIG} | grep "myself" | grep "master" && \

0 commit comments

Comments
 (0)