mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
resolve the gateway deadlock problem
This commit is contained in:
parent
b92e30fa4a
commit
bed57ab802
@ -120,7 +120,7 @@ func (g *GWServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.BoolVar(&g.Debug, "debug", false, "enable pprof debug")
|
||||
fs.Uint64Var(&g.ShareMemory, "max-config-share-memory", 128, "Nginx maximum Shared memory size, which should be increased for larger clusters.")
|
||||
fs.Float32Var(&g.SyncRateLimit, "sync-rate-limit", 0.3, "Define the sync frequency upper limit")
|
||||
fs.StringArrayVar(&g.IgnoreInterface, "ignore-interface", []string{"docker0", "tunl0"}, "The network interface name that ignore by gateway")
|
||||
fs.StringArrayVar(&g.IgnoreInterface, "ignore-interface", []string{"docker0", "tunl0", "cni0", "kube-ipvs0", "flannel"}, "The network interface name that ignore by gateway")
|
||||
}
|
||||
|
||||
// SetLog sets log
|
||||
|
@ -87,6 +87,7 @@ func (i *ipManager) IPInCurrentHost(in net.IP) bool {
|
||||
|
||||
func (i *ipManager) Start() error {
|
||||
logrus.Info("start ip manager.")
|
||||
go i.IPPool.LoopCheckIPs()
|
||||
i.IPPool.Ready()
|
||||
logrus.Info("ip manager is ready.")
|
||||
go i.syncIP()
|
||||
|
@ -45,7 +45,8 @@ type IPPool struct {
|
||||
EventCh chan IPEVENT
|
||||
StopCh chan struct{}
|
||||
ignoreInterfaceName []string
|
||||
startReady bool
|
||||
startReady chan struct{}
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
const (
|
||||
@ -64,21 +65,19 @@ func NewIPPool(ignoreInterfaceName []string) *IPPool {
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
HostIPs: map[string]net.IP{},
|
||||
EventCh: make(chan IPEVENT, 20),
|
||||
EventCh: make(chan IPEVENT, 1024),
|
||||
StopCh: make(chan struct{}),
|
||||
ignoreInterfaceName: ignoreInterfaceName,
|
||||
startReady: false,
|
||||
startReady: make(chan struct{}),
|
||||
}
|
||||
go ippool.LoopCheckIPs()
|
||||
return ippool
|
||||
}
|
||||
|
||||
//Ready ready
|
||||
func (i *IPPool) Ready() bool {
|
||||
for !i.startReady {
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
return i.startReady
|
||||
logrus.Info("waiting ip pool start ready")
|
||||
<-i.startReady
|
||||
return true
|
||||
}
|
||||
|
||||
//GetHostIPs get host ips
|
||||
@ -105,6 +104,7 @@ func (i *IPPool) Close() {
|
||||
//LoopCheckIPs loop check ips
|
||||
func (i *IPPool) LoopCheckIPs() {
|
||||
Exec(i.ctx, func() error {
|
||||
logrus.Debugf("start loop watch ips from all interface")
|
||||
ips, err := i.getInterfaceIPs()
|
||||
if err != nil {
|
||||
logrus.Errorf("get ip address from interface failure %s, will retry", err.Error())
|
||||
@ -133,7 +133,9 @@ func (i *IPPool) LoopCheckIPs() {
|
||||
}
|
||||
logrus.Debugf("loop watch ips from all interface, find %d ips", len(newIP))
|
||||
i.HostIPs = newIP
|
||||
i.startReady = true
|
||||
i.once.Do(func() {
|
||||
close(i.startReady)
|
||||
})
|
||||
return nil
|
||||
}, time.Second*5)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user