Skip to content

Commit

Permalink
fixup! Introduce VPC controller (linode#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbang-akamai committed Feb 8, 2024
1 parent b875552 commit 723e4b0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions controller/linodevpc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

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

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

err = errors.Join(err, patchErr)
Expand Down

0 comments on commit 723e4b0

Please sign in to comment.