Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ingress state build failure when ingresses reference non-existe… #33

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

mtweten
Copy link
Contributor

@mtweten mtweten commented Nov 17, 2023

…nt ingress classes

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

…nt ingress classes

Signed-off-by: Michael Tweten <Michael.Tweten@oracle.com>
Copy link
Contributor

@Inbaraj-S Inbaraj-S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, Minor change to test case.

- Update test-ingress-state_withnamedclasses.yaml
@Inbaraj-S Inbaraj-S self-requested a review February 6, 2024 06:05
Copy link
Contributor

@Inbaraj-S Inbaraj-S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@coveralls
Copy link

Pull Request Test Coverage Report for Build 7795412898

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 0 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 65.303%

Totals Coverage Status
Change from base Build 6861469711: 0.04%
Covered Lines: 2234
Relevant Lines: 3421

💛 - Coveralls

@Inbaraj-S Inbaraj-S merged commit 913ccdd into oracle:main Feb 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants