From 4463098c829b66bc33c628cf817f65b865de45c1 Mon Sep 17 00:00:00 2001 From: Satish Matti Date: Mon, 8 Jun 2020 22:58:44 -0700 Subject: [PATCH] Ensure ingress cleanup when finalizer exists --- pkg/controller/controller.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 4fb268b8de..df3f880f9a 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -165,20 +165,22 @@ func NewLoadBalancerController( UpdateFunc: func(old, cur interface{}) { curIng := cur.(*v1beta1.Ingress) if !utils.IsGLBCIngress(curIng) { - oldIng := old.(*v1beta1.Ingress) - // If ingress was GLBC Ingress, we need to track ingress class change - // and run GC to delete LB resources. - if utils.IsGLBCIngress(oldIng) { - klog.V(4).Infof("Ingress %v class was changed, enqueuing", common.NamespacedName(curIng)) + // Ingress needs to be enqueued if a ingress finalizer exists. + // An existing finalizer means that + // 1. Ingress update for class change. + // 2. Ingress cleanup failed and re-queued. + // 3. Finalizer remove failed nad re-queued. + if common.HasFinalizer(curIng.ObjectMeta) { + klog.V(2).Infof("Ingress %s class was changed but has a finalizer, enqueuing", common.NamespacedName(curIng)) lbc.ingQueue.Enqueue(cur) return } return } if reflect.DeepEqual(old, cur) { - klog.V(3).Infof("Periodic enqueueing of %v", common.NamespacedName(curIng)) + klog.V(3).Infof("Periodic enqueueing of %s", common.NamespacedName(curIng)) } else { - klog.V(3).Infof("Ingress %v changed, enqueuing", common.NamespacedName(curIng)) + klog.V(3).Infof("Ingress %s changed, enqueuing", common.NamespacedName(curIng)) } lbc.ingQueue.Enqueue(cur)