From 92b4902b8d5e048d8c3ec4b80f8327a78218725e Mon Sep 17 00:00:00 2001 From: Rob Murray Date: Fri, 14 Nov 2025 11:17:58 +0000 Subject: [PATCH] Daemon.registerMountPoints: var 'container' -> 'ctr' Signed-off-by: Rob Murray --- daemon/volumes.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/daemon/volumes.go b/daemon/volumes.go index 945e37a2fb..59a277ec20 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -67,7 +67,7 @@ func sortMounts(m []container.Mount) []container.Mount { // 2. Select the volumes mounted from another containers. Overrides previously configured mount point destination. // 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) { +func (daemon *Daemon) registerMountPoints(ctr *container.Container, hostConfig *containertypes.HostConfig, defaultReadOnlyNonRecursive bool) (retErr error) { binds := map[string]bool{} mountPoints := map[string]*volumemounts.MountPoint{} parser := volumemounts.NewParser() @@ -80,7 +80,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo if m.Volume == nil { continue } - daemon.volumes.Release(ctx, m.Volume.Name(), container.ID) + daemon.volumes.Release(ctx, m.Volume.Name(), ctr.ID) } } }() @@ -89,13 +89,13 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo if v, ok := mountPoints[destination]; ok { log.G(ctx).Debugf("Duplicate mount point '%s'", destination) if v.Volume != nil { - daemon.volumes.Release(ctx, v.Volume.Name(), container.ID) + daemon.volumes.Release(ctx, v.Volume.Name(), ctr.ID) } } } // 1. Read already configured mount points. - for destination, point := range container.MountPoints { + for destination, point := range ctr.MountPoints { mountPoints[destination] = point } @@ -125,7 +125,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo } if cp.Source == "" { - v, err := daemon.volumes.Get(ctx, cp.Name, volumeopts.WithGetDriver(cp.Driver), volumeopts.WithGetReference(container.ID)) + v, err := daemon.volumes.Get(ctx, cp.Name, volumeopts.WithGetDriver(cp.Driver), volumeopts.WithGetReference(ctr.ID)) if err != nil { return err } @@ -158,7 +158,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo if bind.Type == mounttypes.TypeVolume { // create the volume - v, err := daemon.volumes.Create(ctx, bind.Name, bind.Driver, volumeopts.WithCreateReference(container.ID)) + v, err := daemon.volumes.Create(ctx, bind.Name, bind.Driver, volumeopts.WithCreateReference(ctr.ID)) if err != nil { return err } @@ -212,12 +212,12 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo v, err = daemon.volumes.Create(ctx, mp.Name, mp.Driver, - volumeopts.WithCreateReference(container.ID), + volumeopts.WithCreateReference(ctr.ID), volumeopts.WithCreateOptions(driverOpts), volumeopts.WithCreateLabels(cfg.VolumeOptions.Labels), ) } else { - v, err = daemon.volumes.Create(ctx, mp.Name, mp.Driver, volumeopts.WithCreateReference(container.ID)) + v, err = daemon.volumes.Create(ctx, mp.Name, mp.Driver, volumeopts.WithCreateReference(ctr.ID)) } if err != nil { return err @@ -254,13 +254,13 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo } rwLayerOpts := &layer.CreateRWLayerOpts{ - StorageOpt: container.HostConfig.StorageOpt, + StorageOpt: ctr.HostConfig.StorageOpt, } // Include the destination in the layer name to make it unique for each mount point and container. // This makes sure that the same image can be mounted multiple times with different destinations. // Hex encode the destination to create a safe, unique identifier - layerName := hex.EncodeToString([]byte(container.ID + ",src=" + mp.Source + ",dst=" + mp.Destination)) + layerName := hex.EncodeToString([]byte(ctr.ID + ",src=" + mp.Source + ",dst=" + mp.Destination)) layer, err := daemon.imageService.CreateLayerFromImage(img, layerName, rwLayerOpts) if err != nil { return err @@ -291,19 +291,19 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo mountPoints[mp.Destination] = mp } - container.Lock() + ctr.Lock() // 4. Cleanup old volumes that are about to be reassigned. for _, m := range mountPoints { if parser.IsBackwardCompatible(m) { - if mp, exists := container.MountPoints[m.Destination]; exists && mp.Volume != nil { - daemon.volumes.Release(ctx, mp.Volume.Name(), container.ID) + if mp, exists := ctr.MountPoints[m.Destination]; exists && mp.Volume != nil { + daemon.volumes.Release(ctx, mp.Volume.Name(), ctr.ID) } } } - container.MountPoints = mountPoints + ctr.MountPoints = mountPoints - container.Unlock() + ctr.Unlock() return nil }