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 kubectl describe ingress when default backend is empty #113664
Fix kubectl describe ingress when default backend is empty #113664
Conversation
Welcome @laphets! |
Hi @laphets. Thanks for your PR. I'm waiting for a kubernetes 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. |
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 the fix!
@@ -2653,11 +2658,7 @@ func (i *IngressDescriber) describeIngressV1(ing *networkingv1.Ingress, events * | |||
w.Write(LEVEL_0, "Ingress Class:\t%v\n", ingressClassName) | |||
def := ing.Spec.DefaultBackend | |||
ns := ing.Namespace | |||
if def == 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.
Don't we do the same thing already in here?. Sorry, but I don't understand what has been fixed/changed with this PR.
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.
Doing this check is not enough, when def == nil
, and there is no any ing.Spec.Rules
, in
w.Write(LEVEL_1, "%s\t%s\t%s\n", "*", "*", i.describeBackendV1(ns, def)) |
it will dereference
nil
inside i.describeBackendV1(ns, def)
.
@@ -2800,6 +2800,30 @@ Rules: | |||
* * default-backend:80 (<error: endpoints "default-backend" not found>) | |||
Annotations: <none> | |||
Events: <none> | |||
`, |
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.
This test should fail without your changes?
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.
It won't fail as the DefaultBackend
is set with &backendV1
, my change fixes the case when DefaultBackend
is nil
.
ca95888
to
653edeb
Compare
/assign brianpursley soltysh ardaguclu |
/ok-to-test |
/triage accepted |
Added unit test is failing without the patch(I tried on my local) and it verifies that this patch fixes problem. Thanks @laphets /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ardaguclu, laphets 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 |
What type of PR is this?
/kind bug
/sig cli
What this PR does / why we need it:
Check ingress backend to prevent a dereference
nil
panic, when the value isnil
, return<default>
.This fixes regression introduced by #108506.
Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#1316
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: