mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-11-01 19:21:04 +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 {
|
||||
|
||||
var err error
|
||||
var nscStopCh, npcStopCh, nrcStopCh chan struct{}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
stopCh := make(chan struct{})
|
||||
|
||||
err = kr.startApiWatchers()
|
||||
if err != nil {
|
||||
return errors.New("Failed to start API watchers: " + err.Error())
|
||||
@ -125,9 +126,9 @@ func (kr *KubeRouter) Run() error {
|
||||
if err != nil {
|
||||
return errors.New("Failed to create network policy controller: " + err.Error())
|
||||
}
|
||||
npcStopCh = make(chan struct{})
|
||||
|
||||
wg.Add(1)
|
||||
go npc.Run(npcStopCh, &wg)
|
||||
go npc.Run(stopCh, &wg)
|
||||
}
|
||||
|
||||
if kr.Config.RunRouter {
|
||||
@ -135,9 +136,9 @@ func (kr *KubeRouter) Run() error {
|
||||
if err != nil {
|
||||
return errors.New("Failed to create network routing controller: " + err.Error())
|
||||
}
|
||||
nrcStopCh = make(chan struct{})
|
||||
|
||||
wg.Add(1)
|
||||
go nrc.Run(nrcStopCh, &wg)
|
||||
go nrc.Run(stopCh, &wg)
|
||||
}
|
||||
|
||||
if kr.Config.RunServiceProxy {
|
||||
@ -145,9 +146,9 @@ func (kr *KubeRouter) Run() error {
|
||||
if err != nil {
|
||||
return errors.New("Failed to create network services controller: " + err.Error())
|
||||
}
|
||||
nscStopCh = make(chan struct{})
|
||||
|
||||
wg.Add(1)
|
||||
go nsc.Run(nscStopCh, &wg)
|
||||
go nsc.Run(stopCh, &wg)
|
||||
}
|
||||
|
||||
// Handle SIGINT and SIGTERM
|
||||
@ -156,15 +157,7 @@ func (kr *KubeRouter) Run() error {
|
||||
<-ch
|
||||
|
||||
glog.Infof("Shutting down the controllers")
|
||||
if kr.Config.RunServiceProxy {
|
||||
nscStopCh <- struct{}{}
|
||||
}
|
||||
if kr.Config.RunFirewall {
|
||||
npcStopCh <- struct{}{}
|
||||
}
|
||||
if kr.Config.RunRouter {
|
||||
nrcStopCh <- struct{}{}
|
||||
}
|
||||
close(stopCh)
|
||||
|
||||
kr.stopApiWatchers()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user