Commit 5f4145f3 authored by Minhan Xia's avatar Minhan Xia

trigger endpoint update on pod deletion

parent d7567cd6
...@@ -215,6 +215,10 @@ func podToEndpointAddress(pod *v1.Pod) *v1.EndpointAddress { ...@@ -215,6 +215,10 @@ func podToEndpointAddress(pod *v1.Pod) *v1.EndpointAddress {
} }
func podChanged(oldPod, newPod *v1.Pod) bool { func podChanged(oldPod, newPod *v1.Pod) bool {
// If the pod's deletion timestamp is set, remove endpoint from ready address.
if newPod.DeletionTimestamp != oldPod.DeletionTimestamp {
return true
}
// If the pod's readiness has changed, the associated endpoint address // If the pod's readiness has changed, the associated endpoint address
// will move from the unready endpoints set to the ready endpoints. // will move from the unready endpoints set to the ready endpoints.
// So for the purposes of an endpoint, a readiness change on a pod // So for the purposes of an endpoint, a readiness change on a pod
......
...@@ -1039,6 +1039,13 @@ func TestPodChanged(t *testing.T) { ...@@ -1039,6 +1039,13 @@ func TestPodChanged(t *testing.T) {
t.Errorf("Expected pod to be changed with pod readiness change") t.Errorf("Expected pod to be changed with pod readiness change")
} }
oldPod.Status.Conditions = saveConditions oldPod.Status.Conditions = saveConditions
now := metav1.NewTime(time.Now().UTC())
newPod.ObjectMeta.DeletionTimestamp = &now
if !podChanged(oldPod, newPod) {
t.Errorf("Expected pod to be changed with DeletionTimestamp change")
}
newPod.ObjectMeta.DeletionTimestamp = oldPod.ObjectMeta.DeletionTimestamp.DeepCopy()
} }
func TestDetermineNeededServiceUpdates(t *testing.T) { func TestDetermineNeededServiceUpdates(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment