Skip to content

Commit

Permalink
fix: ClusterSlaves result should be cut (#884)
Browse files Browse the repository at this point in the history
Signed-off-by: drivebyer <yang.wu@daocloud.io>
  • Loading branch information
drivebyer authored Apr 20, 2024
1 parent b37366a commit 7999a05
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion k8sutils/cluster-scaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,17 @@ func AddRedisNodeToCluster(ctx context.Context, client kubernetes.Interface, log

// getAttachedFollowerNodeIDs would return a slice of redis followers attached to a redis leader
func getAttachedFollowerNodeIDs(ctx context.Context, redisClient *redis.Client, logger logr.Logger, masterNodeID string) []string {
slaveIDs, err := redisClient.ClusterSlaves(ctx, masterNodeID).Result()
// 3acb029fead40752f432c84f9bed2e639119a573 192.168.84.239:6379@16379,redis-cluster-v1beta2-follower-5 slave e3299968586dd457a8dba04fc6c747cecd38510f 0 1713595736542 6 connected
slaveNodes, err := redisClient.ClusterSlaves(ctx, masterNodeID).Result()
if err != nil {
logger.Error(err, "Failed to get attached follower node IDs", "masterNodeID", masterNodeID)
return nil
}
slaveIDs := make([]string, 0, len(slaveNodes))
for _, slave := range slaveNodes {
stringSlice := strings.Split(slave, " ")
slaveIDs = append(slaveIDs, stringSlice[0])
}
logger.V(1).Info("Slaves Nodes attached to", "node", masterNodeID, "are", slaveIDs)
return slaveIDs
}
Expand Down

0 comments on commit 7999a05

Please sign in to comment.