mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 17:38:50 +00:00
EndpointSlice and Endpoints should treat terminating pods the same
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
@@ -86,30 +86,32 @@ func (r *reconciler) reconcile(service *corev1.Service, pods []*corev1.Pod, exis
|
||||
numDesiredEndpoints := 0
|
||||
|
||||
for _, pod := range pods {
|
||||
if endpointutil.ShouldPodBeInEndpoints(pod) {
|
||||
endpointPorts := getEndpointPorts(service, pod)
|
||||
epHash := endpointutil.NewPortMapKey(endpointPorts)
|
||||
if _, ok := desiredEndpointsByPortMap[epHash]; !ok {
|
||||
desiredEndpointsByPortMap[epHash] = endpointSet{}
|
||||
}
|
||||
if !endpointutil.ShouldPodBeInEndpoints(pod, service.Spec.PublishNotReadyAddresses) {
|
||||
continue
|
||||
}
|
||||
|
||||
if _, ok := desiredMetaByPortMap[epHash]; !ok {
|
||||
desiredMetaByPortMap[epHash] = &endpointMeta{
|
||||
AddressType: addressType,
|
||||
Ports: endpointPorts,
|
||||
}
|
||||
}
|
||||
endpointPorts := getEndpointPorts(service, pod)
|
||||
epHash := endpointutil.NewPortMapKey(endpointPorts)
|
||||
if _, ok := desiredEndpointsByPortMap[epHash]; !ok {
|
||||
desiredEndpointsByPortMap[epHash] = endpointSet{}
|
||||
}
|
||||
|
||||
node, err := r.nodeLister.Get(pod.Spec.NodeName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
endpoint := podToEndpoint(pod, node, service)
|
||||
if len(endpoint.Addresses) > 0 {
|
||||
desiredEndpointsByPortMap[epHash].Insert(&endpoint)
|
||||
numDesiredEndpoints++
|
||||
if _, ok := desiredMetaByPortMap[epHash]; !ok {
|
||||
desiredMetaByPortMap[epHash] = &endpointMeta{
|
||||
AddressType: addressType,
|
||||
Ports: endpointPorts,
|
||||
}
|
||||
}
|
||||
|
||||
node, err := r.nodeLister.Get(pod.Spec.NodeName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
endpoint := podToEndpoint(pod, node, service)
|
||||
if len(endpoint.Addresses) > 0 {
|
||||
desiredEndpointsByPortMap[epHash].Insert(&endpoint)
|
||||
numDesiredEndpoints++
|
||||
}
|
||||
}
|
||||
|
||||
spMetrics := metrics.NewServicePortCache()
|
||||
|
Reference in New Issue
Block a user