Signed-off-by: Alessandro Boch <aboch@docker.com>
| ... | ... |
@@ -81,15 +81,22 @@ func attacherKey(target, containerID string) string {
|
| 81 | 81 |
// waiter who is trying to start or attach the container to the |
| 82 | 82 |
// network. |
| 83 | 83 |
func (c *Cluster) UpdateAttachment(target, containerID string, config *network.NetworkingConfig) error {
|
| 84 |
- c.mu.RLock() |
|
| 84 |
+ c.mu.Lock() |
|
| 85 | 85 |
attacher, ok := c.attachers[attacherKey(target, containerID)] |
| 86 |
- c.mu.RUnlock() |
|
| 87 | 86 |
if !ok || attacher == nil {
|
| 87 |
+ c.mu.Unlock() |
|
| 88 | 88 |
return fmt.Errorf("could not find attacher for container %s to network %s", containerID, target)
|
| 89 | 89 |
} |
| 90 |
+ if attacher.inProgress {
|
|
| 91 |
+ logrus.Debugf("Discarding redundant notice of resource allocation on network %s for task id %s", target, attacher.taskID)
|
|
| 92 |
+ c.mu.Unlock() |
|
| 93 |
+ return nil |
|
| 94 |
+ } |
|
| 95 |
+ attacher.inProgress = true |
|
| 96 |
+ c.mu.Unlock() |
|
| 90 | 97 |
|
| 91 | 98 |
attacher.attachWaitCh <- config |
| 92 |
- close(attacher.attachWaitCh) |
|
| 99 |
+ |
|
| 93 | 100 |
return nil |
| 94 | 101 |
} |
| 95 | 102 |
|