Skip to content

Commit 82af0a6

Browse files
committed
do not care about slave with slave-priority=0
1 parent 42679bc commit 82af0a6

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

pkg/client/redis/client.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,18 @@ func (c *client) GetNumberSentinelSlavesInMemory(ip string, auth *util.AuthConfi
103103
if err != nil {
104104
return 0, err
105105
}
106-
nSlaves := 0
106+
nSlaves := len(slaveInfoBlobs)
107107
OUTER:
108108
for _, slaveInfoBlob := range slaveInfoBlobs {
109109
slaveInfo := reflect.ValueOf(slaveInfoBlob)
110110
for key, value := range slaveInfoBlob.([]interface{}) {
111111
stringValue := value.(string)
112-
// When the master node becomes a slave node, runid will become empty
113-
if stringValue == "runid" {
114-
runID := fmt.Sprintf("%+v", slaveInfo.Index(key+1))
115-
if runID == "" {
116-
nSlaves += 1
117-
continue OUTER
118-
}
119-
}
120112
if stringValue == "slave-priority" {
121113
slavePriority := fmt.Sprintf("%+v", slaveInfo.Index(key+1))
122-
if slavePriority == "1" {
123-
nSlaves += 1
124-
continue OUTER
114+
if slavePriority == "0" {
115+
nSlaves -= 1
125116
}
117+
continue OUTER
126118
}
127119
}
128120
}

0 commit comments

Comments
 (0)