mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
Merge pull request #24718 from chengyli/cinder-volume
fix cinder volume dir umount issue #24717
This commit is contained in:
commit
007e4f06a6
@ -21,6 +21,7 @@ package mount
|
|||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/kubernetes/pkg/util/exec"
|
"k8s.io/kubernetes/pkg/util/exec"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
@ -86,8 +87,13 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) {
|
|||||||
|
|
||||||
// Find the device name.
|
// Find the device name.
|
||||||
deviceName := ""
|
deviceName := ""
|
||||||
|
// If mountPath is symlink, need get its target path.
|
||||||
|
slTarget, err := filepath.EvalSymlinks(mountPath)
|
||||||
|
if err != nil {
|
||||||
|
slTarget = mountPath
|
||||||
|
}
|
||||||
for i := range mps {
|
for i := range mps {
|
||||||
if mps[i].Path == mountPath {
|
if mps[i].Path == slTarget {
|
||||||
deviceName = mps[i].Device
|
deviceName = mps[i].Device
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -99,7 +105,7 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) {
|
|||||||
glog.Warningf("could not determine device for path: %q", mountPath)
|
glog.Warningf("could not determine device for path: %q", mountPath)
|
||||||
} else {
|
} else {
|
||||||
for i := range mps {
|
for i := range mps {
|
||||||
if mps[i].Device == deviceName && mps[i].Path != mountPath {
|
if mps[i].Device == deviceName && mps[i].Path != slTarget {
|
||||||
refs = append(refs, mps[i].Path)
|
refs = append(refs, mps[i].Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,8 +124,13 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
|
|||||||
// Find the device name.
|
// Find the device name.
|
||||||
// FIXME if multiple devices mounted on the same mount path, only the first one is returned
|
// FIXME if multiple devices mounted on the same mount path, only the first one is returned
|
||||||
device := ""
|
device := ""
|
||||||
|
// If mountPath is symlink, need get its target path.
|
||||||
|
slTarget, err := filepath.EvalSymlinks(mountPath)
|
||||||
|
if err != nil {
|
||||||
|
slTarget = mountPath
|
||||||
|
}
|
||||||
for i := range mps {
|
for i := range mps {
|
||||||
if mps[i].Path == mountPath {
|
if mps[i].Path == slTarget {
|
||||||
device = mps[i].Device
|
device = mps[i].Device
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user