/
healer.go
38 lines (31 loc) · 1.16 KB
/
healer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package manager
import (
"context"
"time"
redisv1alpha1 "github.com/dinesh-murugiah/rediscluster-operator/api/v1alpha1"
"github.com/dinesh-murugiah/rediscluster-operator/controllers/heal"
"github.com/dinesh-murugiah/rediscluster-operator/utils/redisutil"
)
type IHeal interface {
Heal(cluster *redisv1alpha1.DistributedRedisCluster, infos *redisutil.ClusterInfos, admin redisutil.IAdmin, context context.Context) (bool, error)
FixTerminatingPods(cluster *redisv1alpha1.DistributedRedisCluster, maxDuration time.Duration) (bool, error)
}
type realHeal struct {
*heal.CheckAndHeal
}
func NewHealer(heal *heal.CheckAndHeal) IHeal {
return &realHeal{heal}
}
func (h *realHeal) Heal(cluster *redisv1alpha1.DistributedRedisCluster, infos *redisutil.ClusterInfos, admin redisutil.IAdmin, context context.Context) (bool, error) {
if actionDone, err := h.FixFailedNodes(cluster, infos, admin, context); err != nil {
return actionDone, err
} else if actionDone {
return actionDone, nil
}
if actionDone, err := h.FixUntrustedNodes(cluster, infos, admin, context); err != nil {
return actionDone, err
} else if actionDone {
return actionDone, nil
}
return false, nil
}