-
Notifications
You must be signed in to change notification settings - Fork 366
/
ensurer.go
60 lines (51 loc) · 1.63 KB
/
ensurer.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package redisfailover
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
redisfailoverv1 "github.com/spotahome/redis-operator/api/redisfailover/v1"
"github.com/spotahome/redis-operator/metrics"
)
// Ensure is called to ensure all of the resources associated with a RedisFailover are created
func (w *RedisFailoverHandler) Ensure(rf *redisfailoverv1.RedisFailover, labels map[string]string, or []metav1.OwnerReference, metricsClient metrics.Recorder) error {
if rf.Spec.Redis.Exporter.Enabled {
if err := w.rfService.EnsureRedisService(rf, labels, or); err != nil {
return err
}
} else {
if err := w.rfService.EnsureNotPresentRedisService(rf); err != nil {
return err
}
}
sentinelsAllowed := rf.SentinelsAllowed()
if sentinelsAllowed {
if err := w.rfService.EnsureSentinelService(rf, labels, or); err != nil {
return err
}
if err := w.rfService.EnsureSentinelConfigMap(rf, labels, or); err != nil {
return err
}
}
if err := w.rfService.EnsureRedisMasterService(rf, labels, or); err != nil {
return err
}
if err := w.rfService.EnsureRedisSlaveService(rf, labels, or); err != nil {
return err
}
if err := w.rfService.EnsureRedisShutdownConfigMap(rf, labels, or); err != nil {
return err
}
if err := w.rfService.EnsureRedisReadinessConfigMap(rf, labels, or); err != nil {
return err
}
if err := w.rfService.EnsureRedisConfigMap(rf, labels, or); err != nil {
return err
}
if err := w.rfService.EnsureRedisStatefulset(rf, labels, or); err != nil {
return err
}
if sentinelsAllowed {
if err := w.rfService.EnsureSentinelDeployment(rf, labels, or); err != nil {
return err
}
}
return nil
}