mirror of https://github.com/k3s-io/k3s
commit
984b7c89e8
|
@ -137,6 +137,7 @@ type iscsiDetacher struct {
|
||||||
host volume.VolumeHost
|
host volume.VolumeHost
|
||||||
mounter mount.Interface
|
mounter mount.Interface
|
||||||
manager diskManager
|
manager diskManager
|
||||||
|
plugin *iscsiPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ volume.Detacher = &iscsiDetacher{}
|
var _ volume.Detacher = &iscsiDetacher{}
|
||||||
|
@ -148,6 +149,7 @@ func (plugin *iscsiPlugin) NewDetacher() (volume.Detacher, error) {
|
||||||
host: plugin.host,
|
host: plugin.host,
|
||||||
mounter: plugin.host.GetMounter(iscsiPluginName),
|
mounter: plugin.host.GetMounter(iscsiPluginName),
|
||||||
manager: &ISCSIUtil{},
|
manager: &ISCSIUtil{},
|
||||||
|
plugin: plugin,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +162,7 @@ func (detacher *iscsiDetacher) Detach(volumeName string, nodeName types.NodeName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (detacher *iscsiDetacher) UnmountDevice(deviceMountPath string) error {
|
func (detacher *iscsiDetacher) UnmountDevice(deviceMountPath string) error {
|
||||||
unMounter := volumeSpecToUnmounter(detacher.mounter, detacher.host)
|
unMounter := volumeSpecToUnmounter(detacher.mounter, detacher.host, detacher.plugin)
|
||||||
err := detacher.manager.DetachDisk(*unMounter, deviceMountPath)
|
err := detacher.manager.DetachDisk(*unMounter, deviceMountPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("iscsi: failed to detach disk: %s\nError: %v", deviceMountPath, err)
|
return fmt.Errorf("iscsi: failed to detach disk: %s\nError: %v", deviceMountPath, err)
|
||||||
|
@ -225,11 +227,11 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost, targetLocks
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func volumeSpecToUnmounter(mounter mount.Interface, host volume.VolumeHost) *iscsiDiskUnmounter {
|
func volumeSpecToUnmounter(mounter mount.Interface, host volume.VolumeHost, plugin *iscsiPlugin) *iscsiDiskUnmounter {
|
||||||
exec := host.GetExec(iscsiPluginName)
|
exec := host.GetExec(iscsiPluginName)
|
||||||
return &iscsiDiskUnmounter{
|
return &iscsiDiskUnmounter{
|
||||||
iscsiDisk: &iscsiDisk{
|
iscsiDisk: &iscsiDisk{
|
||||||
plugin: &iscsiPlugin{},
|
plugin: plugin,
|
||||||
},
|
},
|
||||||
mounter: mounter,
|
mounter: mounter,
|
||||||
exec: exec,
|
exec: exec,
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -34,7 +35,6 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
||||||
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
|
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -553,10 +553,18 @@ func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, mntPath string) error {
|
||||||
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mntPath)
|
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mntPath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := c.mounter.Unmount(mntPath); err != nil {
|
|
||||||
glog.Errorf("iscsi detach disk: failed to unmount: %s\nError: %v", mntPath, err)
|
notMnt, err := c.mounter.IsLikelyNotMountPoint(mntPath)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if !notMnt {
|
||||||
|
if err := c.mounter.Unmount(mntPath); err != nil {
|
||||||
|
glog.Errorf("iscsi detach disk: failed to unmount: %s\nError: %v", mntPath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if device is no longer used, see if need to logout the target
|
// if device is no longer used, see if need to logout the target
|
||||||
device, prefix, err := extractDeviceAndPrefix(mntPath)
|
device, prefix, err := extractDeviceAndPrefix(mntPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue