Avoid double close of agentInitDone#1415
Conversation
|
@mrjana There is only one |
|
Yeah we sometimes get more than one notification from engine. That may or may not be fixed. But from libnetwork point of view we should not panic on such events so to make it robust we have to make once instance of channel agenInitDone go through only one iteration of wait and close. |
| c.Lock() | ||
| if c.agent != nil { | ||
| close(c.agentInitDone) | ||
| c.agentInitDone = make(chan struct{}) |
There was a problem hiding this comment.
agentSetup() and SetupIngress (caller of AgentInitWait) can get called from different async paths. With the earlier behavior of only closing the channel, even if SetupIngress gets called later it would return immediately if the agent has already been setup. But by creating the channel right after closing it won't it result in AgentInitWait waiting forever if SetupIngress gets called later ?
There was a problem hiding this comment.
Thanks for spotting. Yeah agree that this could cause a problem. We may have to use c.agentInitDone as a tristate:
- once initdone close it and make
c.agentInitDonenil - if it is nil then it is already closed so waiter doesn't need to wait and simply return
- if it is not nil then cache it and wait
- Recreate the channel only on a leave
Avoid by reinitializing the channel immediately after closing the channel within a lock. Also change the wait code to cache the channel in stack be retrieving it from controller and wait on the stack copy of the channel. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
|
LGTM |
Avoid by reinitializing the channel immediately after closing the
channel within a lock. Also change the wait code to cache the channel in
stack be retrieving it from controller and wait on the stack copy of the
channel.
Signed-off-by: Jana Radhakrishnan mrjana@docker.com