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

Merge pull request #1214 from mrjana/agent

Add agent initialization wait method in controller
This commit is contained in:
Madhu Venugopal 2016-06-05 19:55:16 -07:00
commit c2662da3e9

View file

@ -114,6 +114,9 @@ type NetworkController interface {
// SetClusterProvider sets cluster provider
SetClusterProvider(provider cluster.Provider)
// Wait for agent initialization complete in libnetwork controller
AgentInitWait()
}
// NetworkWalker is a client provided function which will be used to walk the Networks.
@ -143,6 +146,7 @@ type controller struct {
ingressSandbox *sandbox
sboxOnce sync.Once
agent *agent
agentInitDone chan struct{}
sync.Mutex
}
@ -159,6 +163,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
sandboxes: sandboxTable{},
svcRecords: make(map[string]svcInfo),
serviceBindings: make(map[string]*service),
agentInitDone: make(chan struct{}),
}
if err := c.initStores(); err != nil {
@ -248,6 +253,10 @@ func (c *controller) clusterAgentInit() {
}
return false
})
if c.agent != nil {
close(c.agentInitDone)
}
}
}
if remoteAddr != "" {
@ -262,6 +271,12 @@ func (c *controller) clusterAgentInit() {
}
}
// AgentInitWait waits for agent initialization to be completed in the
// controller.
func (c *controller) AgentInitWait() {
<-c.agentInitDone
}
func (c *controller) makeDriverConfig(ntype string) map[string]interface{} {
if c.cfg == nil {
return nil