1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add AgentStopWait method

- to signal when the networking cluster agent is stopped

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2017-04-05 10:38:24 -07:00
parent 7ee02a3176
commit 18098ab1c8
2 changed files with 22 additions and 0 deletions

View file

@ -218,6 +218,7 @@ func (c *controller) agentSetup() error {
if c.agent != nil && c.agentInitDone != nil {
close(c.agentInitDone)
c.agentInitDone = nil
c.agentStopDone = make(chan struct{})
}
c.Unlock()

View file

@ -127,6 +127,9 @@ type NetworkController interface {
// Wait for agent initialization complete in libnetwork controller
AgentInitWait()
// Wait for agent to stop if running
AgentStopWait()
// SetKeys configures the encryption key for gossip and overlay data path
SetKeys(keys []*types.EncryptionKey) error
}
@ -160,6 +163,7 @@ type controller struct {
agent *agent
networkLocker *locker.Locker
agentInitDone chan struct{}
agentStopDone chan struct{}
keys []*types.EncryptionKey
clusterConfigAvailable bool
sync.Mutex
@ -337,6 +341,14 @@ func (c *controller) clusterAgentInit() {
// service bindings
c.agentClose()
c.cleanupServiceBindings("")
c.Lock()
if c.agentStopDone != nil {
close(c.agentStopDone)
c.agentStopDone = nil
}
c.Unlock()
return
}
}
@ -354,6 +366,15 @@ func (c *controller) AgentInitWait() {
}
}
func (c *controller) AgentStopWait() {
c.Lock()
agentStopDone := c.agentStopDone
c.Unlock()
if agentStopDone != nil {
<-agentStopDone
}
}
func (c *controller) makeDriverConfig(ntype string) map[string]interface{} {
if c.cfg == nil {
return nil