oracle / oci-native-ingress-controller

OCI Native Ingress Controller
https://blogs.oracle.com/cloud-infrastructure/post/oracle-cloud-native-ingress-controller-kubernetes
Universal Permissive License v1.0
17 stars 19 forks source link

Ingress state fails to build when an ingress exists which references a non-existent ingress class #34

Closed mtweten closed 3 months ago

mtweten commented 7 months ago

Problem

If any Ingress exists that references a non-existent IngressClass, oci-native-ingress-controller will no longer be able to build the ingress state for any IngressClass, rendering it non-functional

Cause

When building the ingress state for a given IngressClass, this code lists and iterates through all Ingress objects, and tries to determine if the Ingress is tied to the IngressClass being processed (i.e. via ingressClassName, or, if the Ingress has no ingressClassName defined, if the IngressClass is the default ingress class).

In doing this, for each Ingress object, it's calling util.GetIngressClass, which internally lists all IngressClasses and returns the IngressClass that is tied to the Ingress. However, if the Ingress in question references an IngressClass by name that doesn't exist, util.GetIngressClass will return an error (ingress class not found for ingress). The state building code will then exit early and return that error up the stack, meaning no Ingress state will be built and no load balancer will be updated. As long as ANY Ingress object exists that references an IngressClass that doesn't exist, no state can ever be built.

Solution

Since the ingress state building code is already operating on a specific IngressClass, we don't need to use the util.GetIngressClass code which lists all IngressClasses for every Ingress being processed. Instead, we can just compare the ingressClassName of each ingress against the name of the IngressClass being processed. If it matches, we include it in the group. If the ingressClassName is nil, we only include it if the IngressClass being processed is the default ingress class

I've opened a PR which I think addresses this issue here: https://github.com/oracle/oci-native-ingress-controller/pull/33

Inbaraj-S commented 7 months ago

Thank you for reaching out, will look into it and get back on it.

mtweten commented 6 months ago

Hey @Inbaraj-S, just checking if there has been any update on this? Thanks!

Inbaraj-S commented 5 months ago

Thank you for reaching out. This PR is under review, we will get back to you on this.

Inbaraj-S commented 3 months ago

Fixed as part of release v1.3.2.