[ADD] compare old and new rbd-endpoints

This commit is contained in:
GLYASAI 2019-04-15 18:35:29 +08:00
parent 91b38c2318
commit 19767af977

View File

@ -34,7 +34,7 @@ import (
"github.com/goodrain/rainbond/gateway/controller/openresty"
"github.com/goodrain/rainbond/gateway/metric"
"github.com/goodrain/rainbond/gateway/store"
v1 "github.com/goodrain/rainbond/gateway/v1"
"github.com/goodrain/rainbond/gateway/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/ingress-nginx/task"
@ -258,8 +258,11 @@ func (gwc *GWController) initRbdEndpoints(errCh chan<- error) {
// updateRbdPools updates rainbond pools
func (gwc *GWController) updateRbdPools(edps map[string][]string) {
h, t := gwc.getRbdPools(edps)
//merge app pool
h = append(h, gwc.rhp...)
if h != nil {
//merge app pool
h = append(h, gwc.rhp...)
}
if err := gwc.GWS.UpdatePools(h, t); err != nil {
logrus.Errorf("update rainbond pools failure %s", err.Error())
}
@ -313,9 +316,31 @@ func (gwc *GWController) getRbdPools(edps map[string][]string) ([]*v1.Pool, []*v
}
}
gwc.rrbdp = hpools
if !rrbdpEqual(hpools, gwc.rrbdp) {
gwc.rrbdp = hpools
return hpools, tpools
}
return hpools, tpools
return nil, tpools
}
func rrbdpEqual(a []*v1.Pool, b []*v1.Pool) bool {
if len(a) != len(b) {
return false
}
for _, ap := range a {
flag := false
for _, bp := range b {
if ap.Equals(bp) {
flag = true
break
}
}
if !flag {
return false
}
}
return true
}
// listRbdEndpoints lists rainbond endpoints form etcd