-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: check default ingclass when ingclass is nill #2963
Conversation
Hi @yasinlachiny. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
2486c5f
to
b8641e1
Compare
/ok-to-test |
26b2186
to
e21ebc5
Compare
e21ebc5
to
f0b82e3
Compare
Codecov ReportBase: 54.09% // Head: 54.13% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2963 +/- ##
==========================================
+ Coverage 54.09% 54.13% +0.04%
==========================================
Files 144 144
Lines 8291 8303 +12
==========================================
+ Hits 4485 4495 +10
- Misses 3479 3480 +1
- Partials 327 328 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
pkg/ingress/class_loader.go
Outdated
var defaultClassFound bool | ||
ingClassList := &networking.IngressClassList{} | ||
if err := l.client.List(ctx, ingClassList); err != nil { | ||
return "", fmt.Errorf("failed to fetch ingressClasses, %v", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "", fmt.Errorf("failed to fetch ingressClasses, %v", err.Error()) | |
return "", fmt.Errorf("fetching ingressClasses: %w", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err.Error()
is string. I changed the error format based on other errors
@@ -59,7 +60,7 @@ func Test_defaultClassLoader_Load(t *testing.T) { | |||
}, | |||
}, | |||
}, | |||
wantErr: errors.New("invalid ingress class: spec.ingressClassName is nil"), | |||
wantErr: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should specify want
instead of wantErr
.
Need to add a test where there is a default IngressClass. It should assert that the default IngressClass was used.
Need to add a test where there are two IngressClasses annotated as being the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added multiple test cases
- when IngressClass is ALB - Multiple default classes specified
- when IngressClassName unspecified - Multiple default classes specified
- when IngressClassName unspecified - Default class specified
- when IngressClassName unspecified - Default class unspecified
@@ -43,9 +46,40 @@ type defaultClassLoader struct { | |||
client client.Client | |||
} | |||
|
|||
// GetDefaultIngressClass returns the default IngressClass from the list of IngressClasses. | |||
// If multiple IngressClasses are marked as the default, it returns an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the behavior for when there is no default IngressClass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @johngmyers
Thank you for reviewing my code.
I added the document about it.
Hi @johngmyers |
Thanks for doing this! /lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kishorj, yasinlachiny The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* fix: check default ingclass when ingclass is nill * fix: change the error when the defaul class and ingClassName are nill * test: multiple default class specified * test: when IngressClassName unspecified - Default class unspecified
@yasinlachiny sorry for overlooked this PR, i think we don't need this handling given k8s have a admission webhook to inject the default ingress class, not sure why would we need to check for the annotation in our code |
Issue
Description
Per the documentation, the default ingress class is the one with the
ingressclass.kubernetes.io/is-default-class
annotationSo if the
ingressClassName
isnil
we should check for the default ingress class.To reproduce the issue:
1- Set alb
ingressClass
as a default2- Create an ingress without any
ingressClassName
andkubernetes.io/ingress.class
3- It won't create an alb in AWS but by this PR it will create because the default is alb
I check the default ingress with
GetDefaultIngressClass
function.Checklist
README.md
, or thedocs
directory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯