Skip to content

Commit 6f22b7b

Browse files
authored
update conditions on error for delete operation (#175)
Description of changes: - Update conditions on delete in case of error. Right now the errors from delete are not reflected to the user - I have added a check to treat all errors as recoverable if the resource is being deleted as I am not sure what is the user experience if the resource hits a terminal condition after its deleted. Please advise Testing: Manually introduced an error from sdkDelete and verified it gets updated in conditions By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent eb7dc33 commit 6f22b7b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

templates/pkg/resource/manager.go.tpl

+12-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,18 @@ func (rm *resourceManager) Delete(
146146
// Should never happen... if it does, it's buggy code.
147147
panic("resource manager's Update() method received resource with nil CR object")
148148
}
149-
return rm.sdkDelete(ctx, r)
149+
observed, err := rm.sdkDelete(ctx, r)
150+
if err != nil {
151+
if observed != nil {
152+
return rm.onError(observed, err)
153+
}
154+
return rm.onError(r, err)
155+
}
156+
157+
if observed != nil {
158+
return rm.onSuccess(observed)
159+
}
160+
return rm.onSuccess(r)
150161
}
151162
152163
// ARNFromName returns an AWS Resource Name from a given string name. This

0 commit comments

Comments
 (0)