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

Add disable path overlap validation flag #1

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Conversation

Fsero
Copy link
Collaborator

@Fsero Fsero commented Jan 30, 2024

What this PR does / why we need it:

In kubernetes#5651 there was a request to throw an error when there are two ingresses defining the same host and path, which was implemented as part of the validation webhook.

Despite of this there are clear rules on the ingress controller that
describes what the controller would do in such situation (the oldest rule wins)

Some users are relying on this validation behaviour to prevent
misconfigurations, but there are use cases where allowing it, maybe temporarily, is helpful. Those use cases includes:

@Fsero Fsero self-assigned this Jan 30, 2024
@Fsero Fsero force-pushed the allow_duplicates_4_4_2 branch from ea9a732 to 304fd94 Compare January 30, 2024 11:12
Copy link

@miguelbernadi miguelbernadi left a comment

Choose a reason for hiding this comment

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

Left some nits and a suggestion that needs to be tested.

if disablePathOverlapValidation {
return nil
}

Choose a reason for hiding this comment

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

Wouldn't we get the same behaviour if this check was done over the entire function call? I have not tried it, but reading the code seems we would get the same behaviour and a nicer API (no boolean parameter). Have you tested it?


err = nginx.CheckIngress(duplicatedIngress)
if err == nil {
t.Errorf("expected errors but noone occurred")

Choose a reason for hiding this comment

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

Suggested change
t.Errorf("expected errors but noone occurred")
t.Errorf("expected errors but none occurred")

if err == nil {
t.Errorf("expected errors but noone occurred")
}
t.Run("if disablePathOverlap is enabled should not throw any error", func(t *testing.T) {

Choose a reason for hiding this comment

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

Suggested change
t.Run("if disablePathOverlap is enabled should not throw any error", func(t *testing.T) {
t.Run("when disablePathOverlap is enabled should not throw any error", func(t *testing.T) {

@Fsero Fsero force-pushed the allow_duplicates_4_4_2 branch from 304fd94 to 6a54322 Compare February 1, 2024 09:54
@Fsero
Copy link
Collaborator Author

Fsero commented Feb 1, 2024

@miguelbernadi addressed can you check?

Copy link

@miguelbernadi miguelbernadi left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the comments! Looks good.

  ## What this PR does / why we need it:

In kubernetes#5651 there was a
request to throw an error when there are two ingresses defining the same
host and path, which was implemented as part of the validation webhook.

  Despite of this there are clear rules on the ingress controller that
describes what the controller would do in [such situation (the oldest
rule wins)](https://github.com/kubernetes/ingress-nginx/blob/main/docs/how-it-works.md?plain=1#L27)

  Some users are relying on this validation behaviour to prevent
misconfigurations, but there are use cases where allowing it, maybe
temporarily, is helpful.

Change-Id: I9d4124d1c36876b06d63100cd10988eaf2f41db9
@Fsero Fsero force-pushed the allow_duplicates_4_4_2 branch from 6a54322 to e8a10e1 Compare February 1, 2024 12:06
@Fsero Fsero merged commit f13d937 into SCHIP Feb 1, 2024
15 of 23 checks passed
@Fsero Fsero deleted the allow_duplicates_4_4_2 branch February 14, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants