mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-11-03 04:01:08 +01:00
Merge pull request #133 from Thoro/consolidate-stop-channel
Consolidate multiple stop channels into one
This commit is contained in:
commit
bcb56225d3
@ -107,9 +107,10 @@ func (kr *KubeRouter) stopApiWatchers() {
|
|||||||
func (kr *KubeRouter) Run() error {
|
func (kr *KubeRouter) Run() error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var nscStopCh, npcStopCh, nrcStopCh chan struct{}
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
|
stopCh := make(chan struct{})
|
||||||
|
|
||||||
err = kr.startApiWatchers()
|
err = kr.startApiWatchers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Failed to start API watchers: " + err.Error())
|
return errors.New("Failed to start API watchers: " + err.Error())
|
||||||
@ -125,9 +126,9 @@ func (kr *KubeRouter) Run() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Failed to create network policy controller: " + err.Error())
|
return errors.New("Failed to create network policy controller: " + err.Error())
|
||||||
}
|
}
|
||||||
npcStopCh = make(chan struct{})
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go npc.Run(npcStopCh, &wg)
|
go npc.Run(stopCh, &wg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if kr.Config.RunRouter {
|
if kr.Config.RunRouter {
|
||||||
@ -135,9 +136,9 @@ func (kr *KubeRouter) Run() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Failed to create network routing controller: " + err.Error())
|
return errors.New("Failed to create network routing controller: " + err.Error())
|
||||||
}
|
}
|
||||||
nrcStopCh = make(chan struct{})
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go nrc.Run(nrcStopCh, &wg)
|
go nrc.Run(stopCh, &wg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if kr.Config.RunServiceProxy {
|
if kr.Config.RunServiceProxy {
|
||||||
@ -145,9 +146,9 @@ func (kr *KubeRouter) Run() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Failed to create network services controller: " + err.Error())
|
return errors.New("Failed to create network services controller: " + err.Error())
|
||||||
}
|
}
|
||||||
nscStopCh = make(chan struct{})
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go nsc.Run(nscStopCh, &wg)
|
go nsc.Run(stopCh, &wg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle SIGINT and SIGTERM
|
// Handle SIGINT and SIGTERM
|
||||||
@ -156,15 +157,7 @@ func (kr *KubeRouter) Run() error {
|
|||||||
<-ch
|
<-ch
|
||||||
|
|
||||||
glog.Infof("Shutting down the controllers")
|
glog.Infof("Shutting down the controllers")
|
||||||
if kr.Config.RunServiceProxy {
|
close(stopCh)
|
||||||
nscStopCh <- struct{}{}
|
|
||||||
}
|
|
||||||
if kr.Config.RunFirewall {
|
|
||||||
npcStopCh <- struct{}{}
|
|
||||||
}
|
|
||||||
if kr.Config.RunRouter {
|
|
||||||
nrcStopCh <- struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
kr.stopApiWatchers()
|
kr.stopApiWatchers()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user