From 212baf5e715164649e02fed8aa72f7c6ee8e323d Mon Sep 17 00:00:00 2001 From: zounengren Date: Mon, 11 Jul 2022 21:51:25 +0800 Subject: [PATCH] fix not found Signed-off-by: zounengren --- pkg/controller/evpa/effective_vpa_controller.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/controller/evpa/effective_vpa_controller.go b/pkg/controller/evpa/effective_vpa_controller.go index 786fc4b5d..a9bdd400a 100644 --- a/pkg/controller/evpa/effective_vpa_controller.go +++ b/pkg/controller/evpa/effective_vpa_controller.go @@ -7,6 +7,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" vpatypes "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" @@ -43,8 +44,13 @@ func (c *EffectiveVPAController) Reconcile(ctx context.Context, req ctrl.Request klog.V(4).Infof("Got evpa %s", req.NamespacedName) evpa := &autoscalingapi.EffectiveVerticalPodAutoscaler{} - err := c.Client.Get(ctx, req.NamespacedName, evpa) + err := c.Get(ctx, req.NamespacedName, evpa) if err != nil { + if errors.IsNotFound(err) { + // Object not found, return + klog.V(3).Infof("EffectiveVPA %s has been deleted.", req) + return ctrl.Result{}, nil + } return ctrl.Result{}, err }