mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Make EndpointSlice controller always canonicalize the IPs it writes out
This commit is contained in:
parent
7259742e23
commit
29be52b3f7
@ -782,7 +782,7 @@ func TestSyncService(t *testing.T) {
|
||||
Serving: ptr.To(true),
|
||||
Terminating: ptr.To(false),
|
||||
},
|
||||
Addresses: []string{"fd08::5678:0000:0000:9abc:def0"},
|
||||
Addresses: []string{"fd08::5678:0:0:9abc:def0"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod1"},
|
||||
NodeName: ptr.To("node-1"),
|
||||
},
|
||||
|
@ -370,7 +370,7 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
expectedEndpointPerSlice: map[discovery.AddressType][]discovery.Endpoint{
|
||||
discovery.AddressTypeIPv6: {
|
||||
{
|
||||
Addresses: []string{"1234::5678:0000:0000:9abc:def0"},
|
||||
Addresses: []string{"1234::5678:0:0:9abc:def0"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
@ -398,7 +398,7 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
expectedEndpointPerSlice: map[discovery.AddressType][]discovery.Endpoint{
|
||||
discovery.AddressTypeIPv6: {
|
||||
{
|
||||
Addresses: []string{"1234::5678:0000:0000:9abc:def0"},
|
||||
Addresses: []string{"1234::5678:0:0:9abc:def0"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
@ -425,7 +425,7 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
expectedEndpointPerSlice: map[discovery.AddressType][]discovery.Endpoint{
|
||||
discovery.AddressTypeIPv6: {
|
||||
{
|
||||
Addresses: []string{"1234::5678:0000:0000:9abc:def0"},
|
||||
Addresses: []string{"1234::5678:0:0:9abc:def0"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
|
@ -109,13 +109,15 @@ func getEndpointAddresses(podStatus v1.PodStatus, service *v1.Service, addressTy
|
||||
addresses := []string{}
|
||||
|
||||
for _, podIP := range podStatus.PodIPs {
|
||||
isIPv6PodIP := utilnet.IsIPv6String(podIP.IP)
|
||||
// We parse and restringify the pod IP in case it is in an irregular format.
|
||||
ip := utilnet.ParseIPSloppy(podIP.IP)
|
||||
isIPv6PodIP := utilnet.IsIPv6(ip)
|
||||
if isIPv6PodIP && addressType == discovery.AddressTypeIPv6 {
|
||||
addresses = append(addresses, podIP.IP)
|
||||
addresses = append(addresses, ip.String())
|
||||
}
|
||||
|
||||
if !isIPv6PodIP && addressType == discovery.AddressTypeIPv4 {
|
||||
addresses = append(addresses, podIP.IP)
|
||||
addresses = append(addresses, ip.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user