Skip to content

Commit 122650f

Browse files
authored
Set Terminal Condition if ACK Terminal Error (#318)
Set terminal condition if ACK Terminal Error is thrown. ACK Terminal errors can be used to set terminal conditions if controller validations fail. ``` if *latestStatus == "create-failed" { return nil, ackerr.TerminalError.New(errors.New("cluster cannot be updated as its status is not 'available'.")) } ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 4bbc4f1 commit 122650f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

templates/pkg/resource/sdk.go.tpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package {{ .CRD.Names.Snake }}
44

55
import (
66
"context"
7+
"errors"
78
"reflect"
89
"strings"
910

@@ -218,16 +219,16 @@ func (rm *resourceManager) updateConditions (
218219
syncCondition = condition
219220
}
220221
}
221-
222-
if rm.terminalAWSError(err) || err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound {
222+
var termError *ackerr.TerminalError
223+
if rm.terminalAWSError(err) || err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound || errors.As(err, &termError) {
223224
if terminalCondition == nil {
224225
terminalCondition = &ackv1alpha1.Condition{
225226
Type: ackv1alpha1.ConditionTypeTerminal,
226227
}
227228
ko.Status.Conditions = append(ko.Status.Conditions, terminalCondition)
228229
}
229230
var errorMessage = ""
230-
if err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound {
231+
if err == ackerr.SecretTypeNotSupported || err == ackerr.SecretNotFound || errors.As(err, &termError) {
231232
errorMessage = err.Error()
232233
} else {
233234
awsErr, _ := ackerr.AWSError(err)

0 commit comments

Comments
 (0)