Skip to content

Commit

Permalink
Merge pull request kubernetes#100542 from eddiezane/automated-cherry-…
Browse files Browse the repository at this point in the history
…pick-of-#100505-upstream-release-1.19

Automated cherry pick of kubernetes#100505: Fixed describe ingress causing SEGFAULT
  • Loading branch information
k8s-ci-robot committed Mar 25, 2021
2 parents 3303966 + 03a5a7d commit 819643c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion staging/src/k8s.io/kubectl/pkg/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,11 @@ func (i *IngressDescriber) describeBackendV1(ns string, backend *networkingv1.In
}
if backend.Resource != nil {
ic := backend.Resource
return fmt.Sprintf("APIGroup: %v, Kind: %v, Name: %v", *ic.APIGroup, ic.Kind, ic.Name)
apiGroup := "<none>"
if ic.APIGroup != nil {
apiGroup = fmt.Sprintf("%v", *ic.APIGroup)
}
return fmt.Sprintf("APIGroup: %v, Kind: %v, Name: %v", apiGroup, ic.Kind, ic.Name)
}
return ""
}
Expand Down
42 changes: 42 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,12 @@ func TestDescribeIngress(t *testing.T) {
Name: "bar",
},
}
backendResourceNoAPIGroup := networkingv1.IngressBackend{
Resource: &corev1.TypedLocalObjectReference{
Kind: "foo",
Name: "bar",
},
}

tests := map[string]struct {
input *fake.Clientset
Expand Down Expand Up @@ -1811,6 +1817,42 @@ Rules:
foo.bar.com
/foo APIGroup: example.com, Kind: foo, Name: bar
Annotations: <none>
Events: <none>` + "\n",
},
"IngressRule.HTTP.Paths.Backend.Resource v1 Without APIGroup": {
input: fake.NewSimpleClientset(&networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
Namespace: "foo",
},
Spec: networkingv1.IngressSpec{
Rules: []networkingv1.IngressRule{
{
Host: "foo.bar.com",
IngressRuleValue: networkingv1.IngressRuleValue{
HTTP: &networkingv1.HTTPIngressRuleValue{
Paths: []networkingv1.HTTPIngressPath{
{
Path: "/foo",
Backend: backendResourceNoAPIGroup,
},
},
},
},
},
},
},
}),
output: `Name: bar
Namespace: foo
Address:
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
foo.bar.com
/foo APIGroup: <none>, Kind: foo, Name: bar
Annotations: <none>
Events: <none>` + "\n",
},
"Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": {
Expand Down

0 comments on commit 819643c

Please sign in to comment.