-
Notifications
You must be signed in to change notification settings - Fork 151
/
health.go
103 lines (81 loc) · 1.71 KB
/
health.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package storage
func (s *Storage) MarkStoresCorrupted() error {
var markingErr error
for _, h := range s.healthTrackers {
if err := h.MarkCorrupted(); err != nil {
markingErr = err
}
}
return markingErr
}
func (s *Storage) MarkStoresTainted() error {
var markingErr error
for _, h := range s.healthTrackers {
if err := h.MarkTainted(); err != nil {
markingErr = err
}
}
return markingErr
}
func (s *Storage) MarkStoresHealthy() error {
for _, h := range s.healthTrackers {
if err := h.MarkHealthy(); err != nil {
return err
}
}
return nil
}
func (s *Storage) AreStoresCorrupted() (bool, error) {
for _, h := range s.healthTrackers {
corrupted, err := h.IsCorrupted()
if err != nil {
return true, err
}
if corrupted {
return true, nil
}
}
return false, nil
}
func (s *Storage) AreStoresTainted() (bool, error) {
for _, h := range s.healthTrackers {
tainted, err := h.IsTainted()
if err != nil {
return true, err
}
if tainted {
return true, nil
}
}
return false, nil
}
func (s *Storage) CheckCorrectStoresVersion() (bool, error) {
for _, h := range s.healthTrackers {
correct, err := h.CheckCorrectStoreVersion()
if err != nil {
return false, err
}
if !correct {
return false, nil
}
}
return true, nil
}
// UpdateStoresVersion tries to migrate the existing data to the new store version.
func (s *Storage) UpdateStoresVersion() (bool, error) {
allCorrect := true
for _, h := range s.healthTrackers {
_, err := h.UpdateStoreVersion()
if err != nil {
return false, err
}
correct, err := h.CheckCorrectStoreVersion()
if err != nil {
return false, err
}
if !correct {
allCorrect = false
}
}
return allCorrect, nil
}