Skip to content

Commit

Permalink
fix: lost replications when followerReplicas bigger than leaderReplicas
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer committed Oct 27, 2022
1 parent 345c544 commit ca1ee12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ testbin/*
*.swp
*.swo
*~
.vscode

docs/build
9 changes: 5 additions & 4 deletions k8sutils/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,16 @@ func createRedisReplicationCommand(cr *redisv1beta1.RedisCluster, leaderPod Redi
func ExecuteRedisReplicationCommand(cr *redisv1beta1.RedisCluster) {
var podIP string
logger := generateRedisManagerLogger(cr.Namespace, cr.ObjectMeta.Name)
replicas := cr.Spec.GetReplicaCounts("follower")
followerCounts := cr.Spec.GetReplicaCounts("follower")
leaderCounts := cr.Spec.GetReplicaCounts("leader")
nodes := checkRedisCluster(cr)
for podCount := 0; podCount <= int(replicas)-1; podCount++ {
for followerIdx := 0; followerIdx <= int(followerCounts)-1; followerIdx++ {
followerPod := RedisDetails{
PodName: cr.ObjectMeta.Name + "-follower-" + strconv.Itoa(podCount),
PodName: cr.ObjectMeta.Name + "-follower-" + strconv.Itoa(followerIdx),
Namespace: cr.Namespace,
}
leaderPod := RedisDetails{
PodName: cr.ObjectMeta.Name + "-leader-" + strconv.Itoa(podCount),
PodName: cr.ObjectMeta.Name + "-leader-" + strconv.Itoa(int(followerIdx)%int(leaderCounts)),
Namespace: cr.Namespace,
}
podIP = getRedisServerIP(followerPod)
Expand Down

0 comments on commit ca1ee12

Please sign in to comment.