Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions daemon/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ func sortMounts(m []container.Mount) []container.Mount {
// 3. Select the bind mounts set by the client. Overrides previously configured mount point destinations.
// 4. Cleanup old volumes that are about to be reassigned.
func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig, defaultReadOnlyNonRecursive bool) (retErr error) {
var volumeMutex sync.Mutex
volumeMutex.Lock()
binds := map[string]bool{}
mountPoints := map[string]*volumemounts.MountPoint{}
parser := volumemounts.NewParser()

ctx := context.TODO()
defer func() {
// clean up the container mountpoints once return with error
if retErr != nil {
for _, m := range mountPoints {
if m.Volume == nil {
continue
}
daemon.volumes.Release(ctx, m.Volume.Name(), container.ID)
for _, m := range mountPoints {
if m.Volume == nil {
continue
}
daemon.volumes.Release(ctx, m.Volume.Name(), container.ID)
}
}()

Expand All @@ -107,9 +107,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo
}

c, err := daemon.GetContainer(containerID)
if err != nil {
return errdefs.InvalidParameter(err)
}
// ignore err

for _, m := range c.MountPoints {
cp := &volumemounts.MountPoint{
Expand Down Expand Up @@ -191,9 +189,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo
return errdefs.InvalidParameter(err)
}
needsSlavePropagation, err := daemon.validateBindDaemonRoot(mp.Spec)
if err != nil {
return err
}
// ignore err
if needsSlavePropagation {
mp.Propagation = mounttypes.PropagationRSlave
}
Expand Down Expand Up @@ -305,6 +301,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo

container.Unlock()

volumeMutex.Unlock()
return nil
}

Expand Down