Skip to content

Commit 723e4b0

Browse files
committed
fixup! Introduce VPC controller (linode#62)
1 parent b875552 commit 723e4b0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

controller/linodevpc_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"time"
2525

2626
corev1 "k8s.io/api/core/v1"
27+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2728
"k8s.io/apimachinery/pkg/runtime"
2829
utilerrors "k8s.io/apimachinery/pkg/util/errors"
2930
"k8s.io/client-go/tools/record"
@@ -122,8 +123,13 @@ func (r *LinodeVPCReconciler) reconcile(
122123
r.Recorder.Event(vpcScope.LinodeVPC, corev1.EventTypeWarning, string(failureReason), err.Error())
123124
}
124125

125-
// Always close the scope when exiting this function so we can persist any LinodeMachine changes.
126-
if patchErr := vpcScope.Close(ctx); patchErr != nil && utilerrors.FilterOut(patchErr) != nil {
126+
// Always close the scope when exiting this function so we can persist
127+
// any LinodeVPC changes.
128+
patchErr := vpcScope.Close(ctx)
129+
// Ignore any resource not found errors when closing the scope. This
130+
// occurs when the VPC object has already been deleted on
131+
// reconcilliation.
132+
if utilerrors.FilterOut(patchErr, apierrors.IsNotFound) != nil {
127133
logger.Error(patchErr, "failed to patch LinodeVPC")
128134

129135
err = errors.Join(err, patchErr)

0 commit comments

Comments
 (0)