@@ -26,18 +26,21 @@ import (
26
26
// sets conditions when volume was promoted successfully.
27
27
func setPromotedCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
28
28
setStatusCondition (conditions , & metav1.Condition {
29
+ Message : v1alpha1 .MessagePromoted ,
29
30
Type : v1alpha1 .ConditionCompleted ,
30
31
Reason : v1alpha1 .Promoted ,
31
32
ObservedGeneration : observedGeneration ,
32
33
Status : metav1 .ConditionTrue ,
33
34
})
34
35
setStatusCondition (conditions , & metav1.Condition {
36
+ Message : v1alpha1 .MessageHealthy ,
35
37
Type : v1alpha1 .ConditionDegraded ,
36
38
Reason : v1alpha1 .Healthy ,
37
39
ObservedGeneration : observedGeneration ,
38
40
Status : metav1 .ConditionFalse ,
39
41
})
40
42
setStatusCondition (conditions , & metav1.Condition {
43
+ Message : v1alpha1 .MessageNotResyncing ,
41
44
Type : v1alpha1 .ConditionResyncing ,
42
45
Reason : v1alpha1 .NotResyncing ,
43
46
ObservedGeneration : observedGeneration ,
@@ -46,26 +49,30 @@ func setPromotedCondition(conditions *[]metav1.Condition, observedGeneration int
46
49
}
47
50
48
51
// sets conditions when volume promotion was failed.
49
- func setFailedPromotionCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
52
+ func setFailedPromotionCondition (conditions * []metav1.Condition , observedGeneration int64 , errMessage string , errFromCephCSI string ) {
50
53
setStatusCondition (conditions , & metav1.Condition {
54
+ Message : errMessage ,
51
55
Type : v1alpha1 .ConditionCompleted ,
52
56
Reason : v1alpha1 .FailedToPromote ,
53
57
ObservedGeneration : observedGeneration ,
54
58
Status : metav1 .ConditionFalse ,
55
59
})
56
60
setStatusCondition (conditions , & metav1.Condition {
61
+ Message : v1alpha1 .MessagePromotionErrorDetected ,
57
62
Type : v1alpha1 .ConditionDegraded ,
58
- Reason : v1alpha1 . Error ,
63
+ Reason : errFromCephCSI ,
59
64
ObservedGeneration : observedGeneration ,
60
65
Status : metav1 .ConditionTrue ,
61
66
})
62
67
setStatusCondition (conditions , & metav1.Condition {
68
+ Message : v1alpha1 .MessageNotResyncing ,
63
69
Type : v1alpha1 .ConditionResyncing ,
64
70
Reason : v1alpha1 .NotResyncing ,
65
71
ObservedGeneration : observedGeneration ,
66
72
Status : metav1 .ConditionFalse ,
67
73
})
68
74
setStatusCondition (conditions , & metav1.Condition {
75
+ Message : v1alpha1 .MessageValidated ,
69
76
Type : v1alpha1 .ConditionValidated ,
70
77
Reason : v1alpha1 .PrerequisiteMet ,
71
78
ObservedGeneration : observedGeneration ,
@@ -76,24 +83,28 @@ func setFailedPromotionCondition(conditions *[]metav1.Condition, observedGenerat
76
83
// sets conditions when volume promotion was failed due to failed validation.
77
84
func setFailedValidationCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
78
85
setStatusCondition (conditions , & metav1.Condition {
86
+ Message : v1alpha1 .MessageFailedPromoted ,
79
87
Type : v1alpha1 .ConditionCompleted ,
80
88
Reason : v1alpha1 .FailedToPromote ,
81
89
ObservedGeneration : observedGeneration ,
82
90
Status : metav1 .ConditionFalse ,
83
91
})
84
92
setStatusCondition (conditions , & metav1.Condition {
93
+ Message : v1alpha1 .MessagePromotionErrorDetected ,
85
94
Type : v1alpha1 .ConditionDegraded ,
86
95
Reason : v1alpha1 .Error ,
87
96
ObservedGeneration : observedGeneration ,
88
97
Status : metav1 .ConditionTrue ,
89
98
})
90
99
setStatusCondition (conditions , & metav1.Condition {
100
+ Message : v1alpha1 .MessageNotResyncing ,
91
101
Type : v1alpha1 .ConditionResyncing ,
92
102
Reason : v1alpha1 .NotResyncing ,
93
103
ObservedGeneration : observedGeneration ,
94
104
Status : metav1 .ConditionFalse ,
95
105
})
96
106
setStatusCondition (conditions , & metav1.Condition {
107
+ Message : v1alpha1 .MessageFailedPreCondition ,
97
108
Type : v1alpha1 .ConditionValidated ,
98
109
Reason : v1alpha1 .PrerequisiteNotMet ,
99
110
ObservedGeneration : observedGeneration ,
@@ -104,12 +115,14 @@ func setFailedValidationCondition(conditions *[]metav1.Condition, observedGenera
104
115
// sets conditions when volume is demoted and ready to use (resync completed).
105
116
func setNotDegradedCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
106
117
setStatusCondition (conditions , & metav1.Condition {
118
+ Message : v1alpha1 .MessageDemoted ,
107
119
Type : v1alpha1 .ConditionDegraded ,
108
120
Reason : v1alpha1 .Healthy ,
109
121
ObservedGeneration : observedGeneration ,
110
122
Status : metav1 .ConditionFalse ,
111
123
})
112
124
setStatusCondition (conditions , & metav1.Condition {
125
+ Message : v1alpha1 .MessageNotResyncing ,
113
126
Type : v1alpha1 .ConditionResyncing ,
114
127
Reason : v1alpha1 .NotResyncing ,
115
128
ObservedGeneration : observedGeneration ,
@@ -120,18 +133,21 @@ func setNotDegradedCondition(conditions *[]metav1.Condition, observedGeneration
120
133
// sets conditions when volume was demoted successfully.
121
134
func setDemotedCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
122
135
setStatusCondition (conditions , & metav1.Condition {
136
+ Message : v1alpha1 .MessageDemoted ,
123
137
Type : v1alpha1 .ConditionCompleted ,
124
138
Reason : v1alpha1 .Demoted ,
125
139
ObservedGeneration : observedGeneration ,
126
140
Status : metav1 .ConditionTrue ,
127
141
})
128
142
setStatusCondition (conditions , & metav1.Condition {
143
+ Message : v1alpha1 .MessageDegraded ,
129
144
Type : v1alpha1 .ConditionDegraded ,
130
145
Reason : v1alpha1 .VolumeDegraded ,
131
146
ObservedGeneration : observedGeneration ,
132
147
Status : metav1 .ConditionTrue ,
133
148
})
134
149
setStatusCondition (conditions , & metav1.Condition {
150
+ Message : v1alpha1 .MessageNotResyncing ,
135
151
Type : v1alpha1 .ConditionResyncing ,
136
152
Reason : v1alpha1 .NotResyncing ,
137
153
ObservedGeneration : observedGeneration ,
@@ -140,20 +156,23 @@ func setDemotedCondition(conditions *[]metav1.Condition, observedGeneration int6
140
156
}
141
157
142
158
// sets conditions when volume demotion was failed.
143
- func setFailedDemotionCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
159
+ func setFailedDemotionCondition (conditions * []metav1.Condition , observedGeneration int64 , errMessage string , errFromCephCSI string ) {
144
160
setStatusCondition (conditions , & metav1.Condition {
161
+ Message : errMessage ,
145
162
Type : v1alpha1 .ConditionCompleted ,
146
163
Reason : v1alpha1 .FailedToDemote ,
147
164
ObservedGeneration : observedGeneration ,
148
165
Status : metav1 .ConditionFalse ,
149
166
})
150
167
setStatusCondition (conditions , & metav1.Condition {
168
+ Message : v1alpha1 .MessageDemotionErrorDetected ,
151
169
Type : v1alpha1 .ConditionDegraded ,
152
- Reason : v1alpha1 . Error ,
170
+ Reason : errFromCephCSI ,
153
171
ObservedGeneration : observedGeneration ,
154
172
Status : metav1 .ConditionTrue ,
155
173
})
156
174
setStatusCondition (conditions , & metav1.Condition {
175
+ Message : v1alpha1 .MessageNotResyncing ,
157
176
Type : v1alpha1 .ConditionResyncing ,
158
177
Reason : v1alpha1 .NotResyncing ,
159
178
ObservedGeneration : observedGeneration ,
@@ -164,18 +183,21 @@ func setFailedDemotionCondition(conditions *[]metav1.Condition, observedGenerati
164
183
// sets conditions when volume resync was triggered successfully.
165
184
func setResyncCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
166
185
setStatusCondition (conditions , & metav1.Condition {
186
+ Message : v1alpha1 .MessageDemoted ,
167
187
Type : v1alpha1 .ConditionCompleted ,
168
188
Reason : v1alpha1 .Demoted ,
169
189
ObservedGeneration : observedGeneration ,
170
190
Status : metav1 .ConditionTrue ,
171
191
})
172
192
setStatusCondition (conditions , & metav1.Condition {
193
+ Message : v1alpha1 .MessageDegraded ,
173
194
Type : v1alpha1 .ConditionDegraded ,
174
195
Reason : v1alpha1 .VolumeDegraded ,
175
196
ObservedGeneration : observedGeneration ,
176
197
Status : metav1 .ConditionTrue ,
177
198
})
178
199
setStatusCondition (conditions , & metav1.Condition {
200
+ Message : v1alpha1 .MessageResyncTriggered ,
179
201
Type : v1alpha1 .ConditionResyncing ,
180
202
Reason : v1alpha1 .ResyncTriggered ,
181
203
ObservedGeneration : observedGeneration ,
@@ -184,20 +206,23 @@ func setResyncCondition(conditions *[]metav1.Condition, observedGeneration int64
184
206
}
185
207
186
208
// sets conditions when volume resync failed.
187
- func setFailedResyncCondition (conditions * []metav1.Condition , observedGeneration int64 ) {
209
+ func setFailedResyncCondition (conditions * []metav1.Condition , observedGeneration int64 , errMessage string , errFromCephCSI string ) {
188
210
setStatusCondition (conditions , & metav1.Condition {
211
+ Message : errMessage ,
189
212
Type : v1alpha1 .ConditionCompleted ,
190
213
Reason : v1alpha1 .FailedToResync ,
191
214
ObservedGeneration : observedGeneration ,
192
215
Status : metav1 .ConditionFalse ,
193
216
})
194
217
setStatusCondition (conditions , & metav1.Condition {
218
+ Message : v1alpha1 .MessageResyncErrorDetected ,
195
219
Type : v1alpha1 .ConditionDegraded ,
196
- Reason : v1alpha1 . Error ,
220
+ Reason : errFromCephCSI ,
197
221
ObservedGeneration : observedGeneration ,
198
222
Status : metav1 .ConditionTrue ,
199
223
})
200
224
setStatusCondition (conditions , & metav1.Condition {
225
+ Message : v1alpha1 .MessageResyncFailed ,
201
226
Type : v1alpha1 .ConditionResyncing ,
202
227
Reason : v1alpha1 .FailedToResync ,
203
228
ObservedGeneration : observedGeneration ,
@@ -223,6 +248,7 @@ func setStatusCondition(existingConditions *[]metav1.Condition, newCondition *me
223
248
existingCondition .LastTransitionTime = metav1 .NewTime (time .Now ())
224
249
}
225
250
251
+ existingCondition .Message = newCondition .Message
226
252
existingCondition .Reason = newCondition .Reason
227
253
existingCondition .ObservedGeneration = newCondition .ObservedGeneration
228
254
}
0 commit comments