Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding status reporting for RecoverableCondition #40

Merged
merged 3 commits into from
Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions templates/pkg/resource/sdk.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ func (rm *resourceManager) updateConditions (

// Terminal condition
var terminalCondition *ackv1alpha1.Condition = nil
var recoverableCondition *ackv1alpha1.Condition = nil
for _, condition := range ko.Status.Conditions {
if condition.Type == ackv1alpha1.ConditionTypeTerminal {
terminalCondition = condition
break
}
if condition.Type == ackv1alpha1.ConditionTypeRecoverable {
recoverableCondition = condition
}
}

Expand All @@ -182,19 +185,43 @@ func (rm *resourceManager) updateConditions (
awsErr, _ := ackerr.AWSError(err)
errorMessage := awsErr.Message()
terminalCondition.Message = &errorMessage
} else if terminalCondition != nil {
terminalCondition.Status = corev1.ConditionFalse
terminalCondition.Message = nil
} else {
// Clear the terminal condition if no longer present
if terminalCondition != nil {
terminalCondition.Status = corev1.ConditionFalse
terminalCondition.Message = nil
}
// Handling Recoverable Conditions
if err != nil {
if recoverableCondition == nil {
// Add a new Condition containing a non-terminal error
recoverableCondition = &ackv1alpha1.Condition{
Type: ackv1alpha1.ConditionTypeRecoverable,
}
ko.Status.Conditions = append(ko.Status.Conditions, recoverableCondition)
}
recoverableCondition.Status = corev1.ConditionTrue
surajkota marked this conversation as resolved.
Show resolved Hide resolved
awsErr, _ := ackerr.AWSError(err)
errorMessage := err.Error()
if awsErr != nil {
errorMessage = awsErr.Message()
}
recoverableCondition.Message = &errorMessage
} else if recoverableCondition != nil {
recoverableCondition.Status = corev1.ConditionFalse
recoverableCondition.Message = nil
}
}


{{- if $updateConditionsCustomMethodName := .CRD.UpdateConditionsCustomMethodName }}
// custom update conditions
customUpdate := rm.{{ $updateConditionsCustomMethodName }}(ko, r, err)
if terminalCondition != nil || customUpdate {
if terminalCondition != nil || recoverableCondition != nil || customUpdate {
return &resource{ko}, true // updated
}
{{- else }}
if terminalCondition != nil {
if terminalCondition != nil || recoverableCondition != nil {
return &resource{ko}, true // updated
}
{{- end }}
Expand Down