From b8d3d4361a407278faa88d35235c248a5c95854c Mon Sep 17 00:00:00 2001 From: Gong Yongjie Date: Fri, 10 Mar 2023 13:15:09 +0800 Subject: [PATCH] with current logic, If IgnoreIngressClass is set false at the beginning, any incoming Ingress will be caught by ingress-controller and written into nginx configuration file even ingress class of the Ingress object doesn't match the IngressClass watched by current ingress-controller. new logic will try get the IngressClass value on incoming Ingress Object. if IngressClass doesn't match the current IngressController, this ingress will be ignored Signed-off-by: Gong Yongjie --- internal/ingress/controller/store/store.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/ingress/controller/store/store.go b/internal/ingress/controller/store/store.go index 7157332c3..ba1e6220c 100644 --- a/internal/ingress/controller/store/store.go +++ b/internal/ingress/controller/store/store.go @@ -465,10 +465,9 @@ func New( var errOld, errCur error var classCur string - if !icConfig.IgnoreIngressClass { - _, errOld = store.GetIngressClass(oldIng, icConfig) - classCur, errCur = store.GetIngressClass(curIng, icConfig) - } + _, errOld = store.GetIngressClass(oldIng, icConfig) + classCur, errCur = store.GetIngressClass(curIng, icConfig) + if errOld != nil && errCur == nil { if hasCatchAllIngressRule(curIng.Spec) && disableCatchAll { klog.InfoS("ignoring update for catch-all ingress because of --disable-catch-all", "ingress", klog.KObj(curIng)) @@ -489,6 +488,9 @@ func New( } recorder.Eventf(curIng, corev1.EventTypeNormal, "Sync", "Scheduled for sync") + } else if errOld != nil && errCur != nil { + klog.InfoS("Ingress doesn't match the ingress class. Skipping update", "ingress", klog.KObj(curIng)) + return } else { klog.V(3).InfoS("No changes on ingress. Skipping update", "ingress", klog.KObj(curIng)) return