Skip to content

Commit 0916df1

Browse files
authored
return nil if observed is nil from a successful delete (#182)
Issue #, if available: aws-controllers-k8s/community#931 Description of changes: Solution 2 in the issue linked above. If `rm.Delete` does not return an error, and observed is also nil, return `nil, nil` to the caller instead of the resource passed to the method. Testing: `make test` Manually using sagemaker controller By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent a866a84 commit 0916df1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

templates/pkg/resource/manager.go.tpl

+7-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ func (rm *resourceManager) Delete(
154154
return rm.onError(r, err)
155155
}
156156
157-
if observed != nil {
158-
return rm.onSuccess(observed)
159-
}
160-
return rm.onSuccess(r)
157+
return rm.onSuccess(observed)
161158
}
162159
163160
// ARNFromName returns an AWS Resource Name from a given string name. This
@@ -266,6 +263,9 @@ func (rm *resourceManager) onError(
266263
r *resource,
267264
err error,
268265
) (acktypes.AWSResource, error) {
266+
if ackcompare.IsNil(r) {
267+
return nil, err
268+
}
269269
r1, updated := rm.updateConditions(r, false, err)
270270
if !updated {
271271
return r, err
@@ -286,6 +286,9 @@ func (rm *resourceManager) onError(
286286
func (rm *resourceManager) onSuccess(
287287
r *resource,
288288
) (acktypes.AWSResource, error) {
289+
if ackcompare.IsNil(r) {
290+
return nil, nil
291+
}
289292
r1, updated := rm.updateConditions(r, true, nil)
290293
if !updated {
291294
return r, nil

0 commit comments

Comments
 (0)