Skip to content

Commit 1bd3d34

Browse files
committed
Remove some dead code in the Endpoints controller
There was code to deal with upgrades from pre-dual-stack-aware apiservers, with a note to "remove when the possibility of upgrading from a cluster that does not support dual stack is nil". (This requires fixing the unit tests to fill in service.Spec.IPFamilies like a modern apiserver would do.)
1 parent 9a9f10b commit 1bd3d34

File tree

2 files changed

+99
-137
lines changed

2 files changed

+99
-137
lines changed

pkg/controller/endpoint/endpoints_controller.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -214,38 +214,12 @@ func (e *Controller) addPod(obj interface{}) {
214214

215215
func podToEndpointAddressForService(svc *v1.Service, pod *v1.Pod) (*v1.EndpointAddress, error) {
216216
var endpointIP string
217-
ipFamily := v1.IPv4Protocol
218217

219-
if len(svc.Spec.IPFamilies) > 0 {
220-
// controller is connected to an api-server that correctly sets IPFamilies
221-
ipFamily = svc.Spec.IPFamilies[0] // this works for headful and headless
222-
} else {
223-
// controller is connected to an api server that does not correctly
224-
// set IPFamilies (e.g. old api-server during an upgrade)
225-
// TODO (khenidak): remove by when the possibility of upgrading
226-
// from a cluster that does not support dual stack is nil
227-
if len(svc.Spec.ClusterIP) > 0 && svc.Spec.ClusterIP != v1.ClusterIPNone {
228-
// headful service. detect via service clusterIP
229-
if utilnet.IsIPv6String(svc.Spec.ClusterIP) {
230-
ipFamily = v1.IPv6Protocol
231-
}
232-
} else {
233-
// Since this is a headless service we use podIP to identify the family.
234-
// This assumes that status.PodIP is assigned correctly (follows pod cidr and
235-
// pod cidr list order is same as service cidr list order). The expectation is
236-
// this is *most probably* the case.
237-
238-
// if the family was incorrectly identified then this will be corrected once the
239-
// upgrade is completed (controller connects to api-server that correctly defaults services)
240-
if utilnet.IsIPv6String(pod.Status.PodIP) {
241-
ipFamily = v1.IPv6Protocol
242-
}
243-
}
244-
}
218+
wantIPv6 := svc.Spec.IPFamilies[0] == v1.IPv6Protocol
245219

246220
// find an ip that matches the family
247221
for _, podIP := range pod.Status.PodIPs {
248-
if (ipFamily == v1.IPv6Protocol) == utilnet.IsIPv6String(podIP.IP) {
222+
if wantIPv6 == utilnet.IsIPv6String(podIP.IP) {
249223
endpointIP = podIP.IP
250224
break
251225
}

0 commit comments

Comments
 (0)