mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix iSCSI and RBD UnmountDevice with mount containers.
Google's configure-helper.sh script bind-mounts /var/lib/kubelet somewhere into /home/kubernetes and thus every mount that Kubernetes does is visible twice in /proc/mounts. iSCSI and RBD should not rely on counting on entries in /proc/mounts and unmount device when Kubernetes thinks it's unusued. Kubernetes tracks the mounts by itself and most of other volume plugins rely on it safely.
This commit is contained in:
parent
b976ebd56a
commit
906fd7529e
@ -396,25 +396,16 @@ func globalPDPathOperation(b iscsiDiskMounter) func(iscsiDiskMounter, string, *I
|
||||
|
||||
// DetachDisk unmounts and detaches a volume from node
|
||||
func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, mntPath string) error {
|
||||
_, cnt, err := mount.GetDeviceNameFromMount(c.mounter, mntPath)
|
||||
if err != nil {
|
||||
glog.Errorf("iscsi detach disk: failed to get device from mnt: %s\nError: %v", mntPath, err)
|
||||
return err
|
||||
}
|
||||
if pathExists, pathErr := volumeutil.PathExists(mntPath); pathErr != nil {
|
||||
return fmt.Errorf("Error checking if path exists: %v", pathErr)
|
||||
} else if !pathExists {
|
||||
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mntPath)
|
||||
return nil
|
||||
}
|
||||
if err = c.mounter.Unmount(mntPath); err != nil {
|
||||
if err := c.mounter.Unmount(mntPath); err != nil {
|
||||
glog.Errorf("iscsi detach disk: failed to unmount: %s\nError: %v", mntPath, err)
|
||||
return err
|
||||
}
|
||||
cnt--
|
||||
if cnt != 0 {
|
||||
return nil
|
||||
}
|
||||
// if device is no longer used, see if need to logout the target
|
||||
device, prefix, err := extractDeviceAndPrefix(mntPath)
|
||||
if err != nil {
|
||||
|
@ -189,21 +189,17 @@ func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
|
||||
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
|
||||
return nil
|
||||
}
|
||||
devicePath, cnt, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath)
|
||||
devicePath, _, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cnt > 1 {
|
||||
return fmt.Errorf("rbd: more than 1 reference counts at %s", deviceMountPath)
|
||||
}
|
||||
if cnt == 1 {
|
||||
// Unmount the device from the device mount point.
|
||||
glog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath)
|
||||
if err = detacher.mounter.Unmount(deviceMountPath); err != nil {
|
||||
return err
|
||||
}
|
||||
glog.V(3).Infof("rbd: successfully umount device mountpath %s", deviceMountPath)
|
||||
// Unmount the device from the device mount point.
|
||||
glog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath)
|
||||
if err = detacher.mounter.Unmount(deviceMountPath); err != nil {
|
||||
return err
|
||||
}
|
||||
glog.V(3).Infof("rbd: successfully umount device mountpath %s", deviceMountPath)
|
||||
|
||||
glog.V(4).Infof("rbd: detaching device %s", devicePath)
|
||||
err = detacher.manager.DetachDisk(detacher.plugin, deviceMountPath, devicePath)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user