mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Do not panic on redundant UpdateAttachment
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
4e290f7a2b
commit
3bf164e48d
2 changed files with 11 additions and 3 deletions
|
@ -126,6 +126,7 @@ type Cluster struct {
|
||||||
type attacher struct {
|
type attacher struct {
|
||||||
taskID string
|
taskID string
|
||||||
config *network.NetworkingConfig
|
config *network.NetworkingConfig
|
||||||
|
inProgress bool
|
||||||
attachWaitCh chan *network.NetworkingConfig
|
attachWaitCh chan *network.NetworkingConfig
|
||||||
attachCompleteCh chan struct{}
|
attachCompleteCh chan struct{}
|
||||||
detachWaitCh chan struct{}
|
detachWaitCh chan struct{}
|
||||||
|
|
|
@ -81,15 +81,22 @@ func attacherKey(target, containerID string) string {
|
||||||
// waiter who is trying to start or attach the container to the
|
// waiter who is trying to start or attach the container to the
|
||||||
// network.
|
// network.
|
||||||
func (c *Cluster) UpdateAttachment(target, containerID string, config *network.NetworkingConfig) error {
|
func (c *Cluster) UpdateAttachment(target, containerID string, config *network.NetworkingConfig) error {
|
||||||
c.mu.RLock()
|
c.mu.Lock()
|
||||||
attacher, ok := c.attachers[attacherKey(target, containerID)]
|
attacher, ok := c.attachers[attacherKey(target, containerID)]
|
||||||
c.mu.RUnlock()
|
|
||||||
if !ok || attacher == nil {
|
if !ok || attacher == nil {
|
||||||
|
c.mu.Unlock()
|
||||||
return fmt.Errorf("could not find attacher for container %s to network %s", containerID, target)
|
return fmt.Errorf("could not find attacher for container %s to network %s", containerID, target)
|
||||||
}
|
}
|
||||||
|
if attacher.inProgress {
|
||||||
|
logrus.Debugf("Discarding redundant notice of resource allocation on network %s for task id %s", target, attacher.taskID)
|
||||||
|
c.mu.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
attacher.inProgress = true
|
||||||
|
c.mu.Unlock()
|
||||||
|
|
||||||
attacher.attachWaitCh <- config
|
attacher.attachWaitCh <- config
|
||||||
close(attacher.attachWaitCh)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue