Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change update strategy #203

Merged
merged 8 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/redisoperator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
description: A Helm chart for the Spotahome Redis Operator
name: redisoperator
version: 3.0.0
version: 3.1.0
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
107 changes: 107 additions & 0 deletions mocks/operator/redisfailover/service/RedisFailoverCheck.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions mocks/operator/redisfailover/service/RedisFailoverHeal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions mocks/service/redis/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions operator/redisfailover/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,61 @@ const (
timeToPrepare = 2 * time.Minute
)

//Checks if the running version of pods are equal to the statefulset one
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
func (r *RedisFailoverHandler) UpdateRedisesPods(rf *redisfailoverv1.RedisFailover) error {
redises, err := r.rfChecker.GetRedisesIPs(rf)
if err != nil {
return err
}

//If we have syincing nodes we finish checks
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
for _, rp := range redises {
sync, err := r.rfChecker.CheckRedisSyncing(rp, rf)
if err != nil {
return err
}
if sync {
//currently syncing, we wait next round
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
return nil
}
}

ssUR, err := r.rfChecker.GetStatefulSetUpdateRevision(rf)
if err != nil {
return err
}

redisesPods, err := r.rfChecker.GetRedisesSlavesPods(rf)
if err != nil {
return err
}

//If some slaves are not in the correct version, delete them
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
for _, pod := range redisesPods {
revision, err := r.rfChecker.GetRedisRevisionHash(pod, rf)
if err != nil {
return err
}
if revision != ssUR {
//Delete pod and wait next round to check if the new one is synced
r.rfHealer.DeletePod(pod, rf)
return nil
}
}

//If all slaves are up and synced, we check master
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
master, err := r.rfChecker.GetRedisesMasterPod(rf)

masterRevision, err := r.rfChecker.GetRedisRevisionHash(master, rf)
if masterRevision != ssUR {
//Delete pod and wait next round to check if the new one is synced
chusAlvarez marked this conversation as resolved.
Show resolved Hide resolved
r.rfHealer.DeletePod(master, rf)
return nil
}

return nil
}

func (r *RedisFailoverHandler) CheckAndHeal(rf *redisfailoverv1.RedisFailover) error {
// Number of redis is equal as the set on the RF spec
// Number of sentinel is equal as the set on the RF spec
Expand Down Expand Up @@ -87,6 +142,11 @@ func (r *RedisFailoverHandler) CheckAndHeal(rf *redisfailoverv1.RedisFailover) e
}
}

err = r.UpdateRedisesPods(rf)
if err != nil {
return err
}

sentinels, err := r.rfChecker.GetSentinelsIPs(rf)
if err != nil {
return err
Expand Down
Loading