@@ -164,10 +164,13 @@ func (rm *resourceManager) updateConditions (
164
164
165
165
// Terminal condition
166
166
var terminalCondition *ackv1alpha1.Condition = nil
167
+ var recoverableCondition *ackv1alpha1.Condition = nil
167
168
for _, condition := range ko.Status.Conditions {
168
169
if condition.Type == ackv1alpha1.ConditionTypeTerminal {
169
170
terminalCondition = condition
170
- break
171
+ }
172
+ if condition.Type == ackv1alpha1.ConditionTypeRecoverable {
173
+ recoverableCondition = condition
171
174
}
172
175
}
173
176
@@ -182,19 +185,43 @@ func (rm *resourceManager) updateConditions (
182
185
awsErr, _ := ackerr.AWSError(err)
183
186
errorMessage := awsErr.Message()
184
187
terminalCondition.Message = &errorMessage
185
- } else if terminalCondition != nil {
186
- terminalCondition.Status = corev1.ConditionFalse
187
- terminalCondition.Message = nil
188
+ } else {
189
+ // Clear the terminal condition if no longer present
190
+ if terminalCondition != nil {
191
+ terminalCondition.Status = corev1.ConditionFalse
192
+ terminalCondition.Message = nil
193
+ }
194
+ // Handling Recoverable Conditions
195
+ if err != nil {
196
+ if recoverableCondition == nil {
197
+ // Add a new Condition containing a non-terminal error
198
+ recoverableCondition = &ackv1alpha1.Condition{
199
+ Type: ackv1alpha1.ConditionTypeRecoverable,
200
+ }
201
+ ko.Status.Conditions = append(ko.Status.Conditions, recoverableCondition)
202
+ }
203
+ recoverableCondition.Status = corev1.ConditionTrue
204
+ awsErr, _ := ackerr.AWSError(err)
205
+ errorMessage := err.Error()
206
+ if awsErr != nil {
207
+ errorMessage = awsErr.Message()
208
+ }
209
+ recoverableCondition.Message = &errorMessage
210
+ } else if recoverableCondition != nil {
211
+ recoverableCondition.Status = corev1.ConditionFalse
212
+ recoverableCondition.Message = nil
213
+ }
188
214
}
189
215
216
+
190
217
{ {- if $updateConditionsCustomMethodName := .CRD.UpdateConditionsCustomMethodName } }
191
218
// custom update conditions
192
219
customUpdate := rm.{ { $updateConditionsCustomMethodName } }(ko, r, err)
193
- if terminalCondition != nil || customUpdate {
220
+ if terminalCondition != nil || recoverableCondition != nil || customUpdate {
194
221
return &resource{ko} , true // updated
195
222
}
196
223
{ {- else } }
197
- if terminalCondition != nil {
224
+ if terminalCondition != nil || recoverableCondition != nil {
198
225
return &resource{ko} , true // updated
199
226
}
200
227
{ {- end } }
0 commit comments