mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 18:58:02 +08:00
Merge pull request #867 from GLYASAI/V5.2
bug fix: not ready ep in /etc/hosts
This commit is contained in:
commit
7e2550c278
@ -3,6 +3,7 @@ package discover
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -90,18 +91,24 @@ func (k *k8sDiscover) discover(name string, callback CallbackUpdate) {
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
pod := obj.(*corev1.Pod)
|
||||
ep := endpointForPod(pod)
|
||||
ep.Mode = 2
|
||||
callback.UpdateEndpoints(config.DELETE, ep)
|
||||
},
|
||||
UpdateFunc: func(old, cur interface{}) {
|
||||
oldPod := old.(*corev1.Pod)
|
||||
curPod := cur.(*corev1.Pod)
|
||||
if oldPod.Status.Phase == curPod.Status.Phase {
|
||||
return
|
||||
}
|
||||
if !isPodReady(curPod) {
|
||||
|
||||
if reflect.DeepEqual(oldPod, curPod) {
|
||||
return
|
||||
}
|
||||
|
||||
ep := endpointForPod(curPod)
|
||||
if !isPodReady(curPod) {
|
||||
logrus.Infof("unready pod(%s%s) received, delete endpoint based on the pod", curPod.Name, curPod.Namespace)
|
||||
ep.Mode = 2
|
||||
callback.UpdateEndpoints(config.DELETE, ep)
|
||||
return
|
||||
}
|
||||
callback.UpdateEndpoints(config.SYNC, ep)
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user