Fix EndpointSlice describe panic when an Endpoint doesn't have zone

Kubernetes-commit: 67494b169413c74c116cf4c238c266810729247a
This commit is contained in:
Quan Tian 2021-04-12 18:15:16 +08:00 committed by Kubernetes Publisher
parent 7cc9aa31e2
commit a78d4d9ab3
2 changed files with 3 additions and 2 deletions

View File

@ -3087,7 +3087,7 @@ func describeEndpointSliceV1(eps *discoveryv1.EndpointSlice, events *corev1.Even
w.Write(LEVEL_2, "NodeName:\t%s\n", nodeNameText) w.Write(LEVEL_2, "NodeName:\t%s\n", nodeNameText)
zoneText := "<unset>" zoneText := "<unset>"
if endpoint.NodeName != nil { if endpoint.Zone != nil {
zoneText = *endpoint.Zone zoneText = *endpoint.Zone
} }
w.Write(LEVEL_2, "Zone:\t%s\n", zoneText) w.Write(LEVEL_2, "Zone:\t%s\n", zoneText)

View File

@ -4874,6 +4874,7 @@ Events: <none>` + "\n",
Addresses: []string{"1.2.3.6", "1.2.3.7"}, Addresses: []string{"1.2.3.6", "1.2.3.7"},
Conditions: discoveryv1.EndpointConditions{Ready: utilpointer.BoolPtr(true)}, Conditions: discoveryv1.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
TargetRef: &corev1.ObjectReference{Kind: "Pod", Name: "test-124"}, TargetRef: &corev1.ObjectReference{Kind: "Pod", Name: "test-124"},
NodeName: utilpointer.StringPtr("node-2"),
}, },
}, },
Ports: []discoveryv1.EndpointPort{ Ports: []discoveryv1.EndpointPort{
@ -4906,7 +4907,7 @@ Endpoints:
Ready: true Ready: true
Hostname: <unset> Hostname: <unset>
TargetRef: Pod/test-124 TargetRef: Pod/test-124
NodeName: <unset> NodeName: node-2
Zone: <unset> Zone: <unset>
Events: <none>` + "\n", Events: <none>` + "\n",
}, },