endpointslices: terminal pods doesn't receive enpoints
This commit is contained in:
@@ -138,6 +138,12 @@ func DeepHashObjectToString(objectToWrite interface{}) string {
|
||||
// ShouldPodBeInEndpointSlice returns true if a specified pod should be in an EndpointSlice object.
|
||||
// Terminating pods are only included if includeTerminating is true
|
||||
func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
|
||||
// "Terminal" describes when a Pod is complete (in a succeeded or failed phase).
|
||||
// This is distinct from the "Terminating" condition which represents when a Pod
|
||||
// is being terminated (metadata.deletionTimestamp is non nil).
|
||||
if podutil.IsPodTerminal(pod) {
|
||||
return false
|
||||
}
|
||||
if len(pod.Status.PodIP) == 0 && len(pod.Status.PodIPs) == 0 {
|
||||
return false
|
||||
}
|
||||
@@ -146,14 +152,6 @@ func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if pod.Spec.RestartPolicy == v1.RestartPolicyNever {
|
||||
return pod.Status.Phase != v1.PodFailed && pod.Status.Phase != v1.PodSucceeded
|
||||
}
|
||||
|
||||
if pod.Spec.RestartPolicy == v1.RestartPolicyOnFailure {
|
||||
return pod.Status.Phase != v1.PodSucceeded
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user