From f08761f5ed01dcf1c8422afdadf8bf50675db5d7 Mon Sep 17 00:00:00 2001 From: Quan Tian Date: Mon, 12 Apr 2021 18:15:16 +0800 Subject: [PATCH] Fix EndpointSlice describe panic when an Endpoint doesn't have zone Kubernetes-commit: 5e6c1a7b8a6d430bf13b9388892e48d1b38f54a3 --- pkg/describe/describe.go | 2 +- pkg/describe/describe_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/describe/describe.go b/pkg/describe/describe.go index b7f9a6840..70850f15c 100644 --- a/pkg/describe/describe.go +++ b/pkg/describe/describe.go @@ -3055,7 +3055,7 @@ func describeEndpointSliceV1(eps *discoveryv1.EndpointSlice, events *corev1.Even w.Write(LEVEL_2, "NodeName:\t%s\n", nodeNameText) zoneText := "" - if endpoint.NodeName != nil { + if endpoint.Zone != nil { zoneText = *endpoint.Zone } w.Write(LEVEL_2, "Zone:\t%s\n", zoneText) diff --git a/pkg/describe/describe_test.go b/pkg/describe/describe_test.go index 01e7d656b..2bb74e786 100644 --- a/pkg/describe/describe_test.go +++ b/pkg/describe/describe_test.go @@ -4874,6 +4874,7 @@ Events: ` + "\n", Addresses: []string{"1.2.3.6", "1.2.3.7"}, Conditions: discoveryv1.EndpointConditions{Ready: utilpointer.BoolPtr(true)}, TargetRef: &corev1.ObjectReference{Kind: "Pod", Name: "test-124"}, + NodeName: utilpointer.StringPtr("node-2"), }, }, Ports: []discoveryv1.EndpointPort{ @@ -4906,7 +4907,7 @@ Endpoints: Ready: true Hostname: TargetRef: Pod/test-124 - NodeName: + NodeName: node-2 Zone: Events: ` + "\n", },