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 <yong-jie.gong@microfocus.com>
This commit is contained in:
Gong Yongjie 2023-03-10 13:15:09 +08:00
parent 4f74e03aad
commit b8d3d4361a

View file

@ -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