From 475bcde64c4c994a1aa58785e07e86b84a8412cf Mon Sep 17 00:00:00 2001 From: Aditya Sharma Date: Tue, 8 Jun 2021 09:27:34 -0700 Subject: [PATCH] Skip validation checks if an ingress is marked as deleted (#7216) Signed-off-by: Aditya Sharma --- internal/ingress/controller/controller.go | 5 +++++ internal/ingress/controller/controller_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index f17f73ef3..966de6f2f 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -214,6 +214,11 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error { return nil } + // Skip checks if the ingress is marked as deleted + if !ing.DeletionTimestamp.IsZero() { + return nil + } + if !class.IsValid(ing) { klog.Warningf("ignoring ingress %v in %v based on annotation %v", ing.Name, ing.ObjectMeta.Namespace, class.IngressKey) return nil diff --git a/internal/ingress/controller/controller_test.go b/internal/ingress/controller/controller_test.go index 0aa522b7f..22d108ca4 100644 --- a/internal/ingress/controller/controller_test.go +++ b/internal/ingress/controller/controller_test.go @@ -294,6 +294,16 @@ func TestCheckIngress(t *testing.T) { } }) }) + + t.Run("When the ingress is marked as deleted", func(t *testing.T) { + ing.DeletionTimestamp = &metav1.Time{ + Time: time.Now(), + } + + if nginx.CheckIngress(ing) != nil { + t.Errorf("when the ingress is marked as deleted, no error should be returned") + } + }) } func TestMergeAlternativeBackends(t *testing.T) {