@@ -75,7 +75,7 @@ func (r *IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
7575 ingress .Name = req .Name
7676
7777 ingress .TypeMeta = metav1.TypeMeta {
78- Kind : "Ingress" ,
78+ Kind : KindIngress ,
7979 APIVersion : networkingv1 .SchemeGroupVersion .String (),
8080 }
8181
@@ -84,8 +84,9 @@ func (r *IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
8484 return ctrl.Result {}, err
8585 }
8686 r .Log .Info ("deleted ingress resources" , "ingress" , ingress .Name )
87+ return ctrl.Result {}, nil
8788 }
88- return ctrl.Result {}, client . IgnoreNotFound ( err )
89+ return ctrl.Result {}, err
8990 }
9091
9192 r .Log .Info ("reconciling ingress" , "ingress" , ingress .Name )
@@ -128,11 +129,7 @@ func (r *IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
128129
129130// checkIngressClass check if the ingress uses the ingress class that we control
130131func (r * IngressReconciler ) checkIngressClass (obj client.Object ) bool {
131- ingress , ok := obj .(* networkingv1.Ingress )
132- if ! ok {
133- r .Log .Error (fmt .Errorf ("unexpected object type" ), "failed to convert object to Ingress" )
134- return false
135- }
132+ ingress := obj .(* networkingv1.Ingress )
136133
137134 if ingress .Spec .IngressClassName == nil {
138135 // handle the case where IngressClassName is not specified
@@ -145,10 +142,8 @@ func (r *IngressReconciler) checkIngressClass(obj client.Object) bool {
145142
146143 // find the ingress class that is marked as default
147144 for _ , ic := range ingressClassList .Items {
148- if ic .Annotations ["ingressclass.kubernetes.io/is-default-class" ] == "true" {
149- if matchesController (ic .Spec .Controller ) {
150- return true
151- }
145+ if IsDefaultIngressClass (& ic ) && matchesController (ic .Spec .Controller ) {
146+ return true
152147 }
153148 }
154149
@@ -162,8 +157,8 @@ func (r *IngressReconciler) checkIngressClass(obj client.Object) bool {
162157 }
163158
164159 // if it does not match, check if the ingress class is controlled by us
165- ingressClass := & networkingv1.IngressClass {}
166- if err := r .Client .Get (context .Background (), client.ObjectKey {Name : * ingress .Spec .IngressClassName }, ingressClass ); err != nil {
160+ ingressClass := networkingv1.IngressClass {}
161+ if err := r .Client .Get (context .Background (), client.ObjectKey {Name : * ingress .Spec .IngressClassName }, & ingressClass ); err != nil {
167162 r .Log .Error (err , "failed to get ingress class" , "ingress" , ingress .GetName (), "ingressclass" , * ingress .Spec .IngressClassName )
168163 return false
169164 }
@@ -279,7 +274,6 @@ func (r *IngressReconciler) processTLS(ctx context.Context, tctx *provider.Trans
279274 Name : tls .SecretName ,
280275 }, & secret ); err != nil {
281276 log .Error (err , "failed to get secret" , "namespace" , ingress .Namespace , "name" , tls .SecretName )
282- // todo: set the ingress condition to false
283277 return err
284278 }
285279
0 commit comments