mirror of
https://github.com/containers/podman.git
synced 2025-09-28 17:25:31 +08:00
build(deps): bump github.com/containers/common from 0.26.0 to 0.26.3
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.26.0 to 0.26.3. - [Release notes](https://github.com/containers/common/releases) - [Commits](containers/common@v0.26.0...v0.26.3) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
96
vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
generated
vendored
96
vendor/github.com/containers/storage/drivers/devmapper/deviceset.go
generated
vendored
@ -1213,7 +1213,11 @@ func (devices *DeviceSet) growFS(info *devInfo) error {
|
||||
return errors.Wrapf(err, "Failed to mount; dmesg: %s", string(dmesg.Dmesg(256)))
|
||||
}
|
||||
|
||||
defer unix.Unmount(fsMountPoint, unix.MNT_DETACH)
|
||||
defer func() {
|
||||
if err := mount.Unmount(fsMountPoint); err != nil {
|
||||
logrus.Warnf("devmapper.growFS cleanup error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
switch devices.BaseDeviceFilesystem {
|
||||
case ext4:
|
||||
@ -2257,6 +2261,38 @@ func (devices *DeviceSet) cancelDeferredRemoval(info *devInfo) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (devices *DeviceSet) unmountAndDeactivateAll(dir string) {
|
||||
files, err := ioutil.ReadDir(dir)
|
||||
if err != nil {
|
||||
logrus.Warnf("devmapper: unmountAndDeactivate: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, d := range files {
|
||||
if !d.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := d.Name()
|
||||
fullname := path.Join(dir, name)
|
||||
|
||||
// We use MNT_DETACH here in case it is still busy in some running
|
||||
// container. This means it'll go away from the global scope directly,
|
||||
// and the device will be released when that container dies.
|
||||
if err := mount.Unmount(fullname); err != nil {
|
||||
logrus.Warnf("devmapper.Shutdown error: %s", err)
|
||||
}
|
||||
|
||||
if devInfo, err := devices.lookupDevice(name); err != nil {
|
||||
logrus.Debugf("devmapper: Shutdown lookup device %s, error: %s", name, err)
|
||||
} else {
|
||||
if err := devices.deactivateDevice(devInfo); err != nil {
|
||||
logrus.Debugf("devmapper: Shutdown deactivate %s, error: %s", devInfo.Hash, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shutdown shuts down the device by unmounting the root.
|
||||
func (devices *DeviceSet) Shutdown(home string) error {
|
||||
logrus.Debugf("devmapper: [deviceset %s] Shutdown()", devices.devicePrefix)
|
||||
@ -2278,45 +2314,7 @@ func (devices *DeviceSet) Shutdown(home string) error {
|
||||
// will be killed and we will not get a chance to save deviceset
|
||||
// metadata. Hence save this early before trying to deactivate devices.
|
||||
devices.saveDeviceSetMetaData()
|
||||
|
||||
// ignore the error since it's just a best effort to not try to unmount something that's mounted
|
||||
mounts, _ := mount.GetMounts()
|
||||
mounted := make(map[string]bool, len(mounts))
|
||||
for _, mnt := range mounts {
|
||||
mounted[mnt.Mountpoint] = true
|
||||
}
|
||||
|
||||
if err := filepath.Walk(path.Join(home, "mnt"), func(p string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if mounted[p] {
|
||||
// We use MNT_DETACH here in case it is still busy in some running
|
||||
// container. This means it'll go away from the global scope directly,
|
||||
// and the device will be released when that container dies.
|
||||
if err := unix.Unmount(p, unix.MNT_DETACH); err != nil {
|
||||
logrus.Debugf("devmapper: Shutdown unmounting %s, error: %s", p, err)
|
||||
}
|
||||
}
|
||||
|
||||
if devInfo, err := devices.lookupDevice(path.Base(p)); err != nil {
|
||||
logrus.Debugf("devmapper: Shutdown lookup device %s, error: %s", path.Base(p), err)
|
||||
} else {
|
||||
if err := devices.deactivateDevice(devInfo); err != nil {
|
||||
logrus.Debugf("devmapper: Shutdown deactivate %s , error: %s", devInfo.Hash, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil && !os.IsNotExist(err) {
|
||||
devices.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
devices.unmountAndDeactivateAll(path.Join(home, "mnt"))
|
||||
devices.Unlock()
|
||||
|
||||
info, _ := devices.lookupDeviceWithLock("")
|
||||
@ -2420,7 +2418,9 @@ func (devices *DeviceSet) MountDevice(hash, path string, moptions graphdriver.Mo
|
||||
|
||||
if fstype == xfs && devices.xfsNospaceRetries != "" {
|
||||
if err := devices.xfsSetNospaceRetries(info); err != nil {
|
||||
unix.Unmount(path, unix.MNT_DETACH)
|
||||
if err := mount.Unmount(path); err != nil {
|
||||
logrus.Warnf("devmapper.MountDevice cleanup error: %v", err)
|
||||
}
|
||||
devices.deactivateDevice(info)
|
||||
return err
|
||||
}
|
||||
@ -2446,11 +2446,23 @@ func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error {
|
||||
defer devices.Unlock()
|
||||
|
||||
logrus.Debugf("devmapper: Unmount(%s)", mountPath)
|
||||
if err := unix.Unmount(mountPath, unix.MNT_DETACH); err != nil {
|
||||
if err := mount.Unmount(mountPath); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Debug("devmapper: Unmount done")
|
||||
|
||||
// Remove the mountpoint here. Removing the mountpoint (in newer kernels)
|
||||
// will cause all other instances of this mount in other mount namespaces
|
||||
// to be killed (this is an anti-DoS measure that is necessary for things
|
||||
// like devicemapper). This is necessary to avoid cases where a libdm mount
|
||||
// that is present in another namespace will cause subsequent RemoveDevice
|
||||
// operations to fail. We ignore any errors here because this may fail on
|
||||
// older kernels which don't have
|
||||
// torvalds/linux@8ed936b5671bfb33d89bc60bdcc7cf0470ba52fe applied.
|
||||
if err := os.Remove(mountPath); err != nil {
|
||||
logrus.Debugf("devmapper: error doing a remove on unmounted device %s: %v", mountPath, err)
|
||||
}
|
||||
|
||||
return devices.deactivateDevice(info)
|
||||
}
|
||||
|
||||
|
32
vendor/github.com/containers/storage/drivers/devmapper/driver.go
generated
vendored
32
vendor/github.com/containers/storage/drivers/devmapper/driver.go
generated
vendored
@ -14,9 +14,9 @@ import (
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/containers/storage/pkg/locker"
|
||||
"github.com/containers/storage/pkg/mount"
|
||||
"github.com/containers/storage/pkg/system"
|
||||
units "github.com/docker/go-units"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -116,11 +116,13 @@ func (d *Driver) Metadata(id string) (map[string]string, error) {
|
||||
func (d *Driver) Cleanup() error {
|
||||
err := d.DeviceSet.Shutdown(d.home)
|
||||
|
||||
if err2 := mount.Unmount(d.home); err == nil {
|
||||
err = err2
|
||||
umountErr := mount.Unmount(d.home)
|
||||
// in case we have two errors, prefer the one from Shutdown()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
return umountErr
|
||||
}
|
||||
|
||||
// CreateFromTemplate creates a layer with the same contents and parent as another layer.
|
||||
@ -148,7 +150,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove removes a device with a given id, unmounts the filesystem.
|
||||
// Remove removes a device with a given id, unmounts the filesystem, and removes the mount point.
|
||||
func (d *Driver) Remove(id string) error {
|
||||
d.locker.Lock(id)
|
||||
defer d.locker.Unlock(id)
|
||||
@ -163,7 +165,21 @@ func (d *Driver) Remove(id string) error {
|
||||
if err := d.DeviceSet.DeleteDevice(id, false); err != nil {
|
||||
return fmt.Errorf("failed to remove device %s: %v", id, err)
|
||||
}
|
||||
return system.EnsureRemoveAll(path.Join(d.home, "mnt", id))
|
||||
|
||||
// Most probably the mount point is already removed on Put()
|
||||
// (see DeviceSet.UnmountDevice()), but just in case it was not
|
||||
// let's try to remove it here as well, ignoring errors as
|
||||
// an older kernel can return EBUSY if e.g. the mount was leaked
|
||||
// to other mount namespaces. A failure to remove the container's
|
||||
// mount point is not important and should not be treated
|
||||
// as a failure to remove the container.
|
||||
mp := path.Join(d.home, "mnt", id)
|
||||
err := unix.Rmdir(mp)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
logrus.WithField("storage-driver", "devicemapper").Warnf("unable to remove mount point %q: %s", mp, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get mounts a device with given id into the root filesystem
|
||||
@ -226,10 +242,12 @@ func (d *Driver) Put(id string) error {
|
||||
if count := d.ctr.Decrement(mp); count > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := d.DeviceSet.UnmountDevice(id, mp)
|
||||
if err != nil {
|
||||
logrus.Errorf("devmapper: Error unmounting device %s: %s", id, err)
|
||||
logrus.Errorf("devmapper: Error unmounting device %s: %v", id, err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user