Skip to content

Commit fda09fd

Browse files
Globally reconcile conflicted Ingresses on deletion (#486)
1 parent f0242cb commit fda09fd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pkg/reconciler/ingress/controller.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,21 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl
194194
})
195195

196196
// Make sure trackers are deleted once the observers are removed.
197+
// Also reconcile all ingresses in conflict once another ingress is removed to
198+
// unwedge them.
197199
ingressInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
198200
FilterFunc: isKourierIngress,
199201
Handler: cache.ResourceEventHandlerFuncs{
200-
DeleteFunc: tracker.OnDeletedObserver,
202+
DeleteFunc: func(obj interface{}) {
203+
tracker.OnDeletedObserver(obj)
204+
205+
impl.FilteredGlobalResync(func(obj interface{}) bool {
206+
lbReady := obj.(*v1alpha1.Ingress).Status.GetCondition(v1alpha1.IngressConditionLoadBalancerReady).GetReason()
207+
// Force reconcile all Kourier ingresses that are either not reconciled yet
208+
// (and thus might end up in a conflict) or already in conflict.
209+
return isKourierIngress(obj) && (lbReady == "" || lbReady == conflictReason)
210+
}, ingressInformer.Informer())
211+
},
201212
},
202213
})
203214

pkg/reconciler/ingress/ingress.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import (
3131
"knative.dev/pkg/reconciler"
3232
)
3333

34+
const conflictReason = "DomainConflict"
35+
3436
type Reconciler struct {
3537
xdsServer *envoy.XdsServer
3638
caches *generator.Caches
@@ -52,7 +54,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ing *v1alpha1.Ingress) r
5254
// If we had an error due to a duplicated domain, we must mark the ingress as failed with a
5355
// custom status. We don't want to return an error in this case as we want to update its status.
5456
logging.FromContext(ctx).Info(err.Error())
55-
ing.Status.MarkLoadBalancerFailed("DomainConflict", "Ingress rejected: "+err.Error())
57+
ing.Status.MarkLoadBalancerFailed(conflictReason, "Ingress rejected: "+err.Error())
5658
return nil
5759
} else if err != nil {
5860
return fmt.Errorf("failed to update ingress: %w", err)

0 commit comments

Comments
 (0)