Skip to content

Commit

Permalink
Merge pull request #24718 from chengyli/cinder-volume
Browse files Browse the repository at this point in the history
fix cinder volume dir umount issue #24717
  • Loading branch information
roberthbailey committed May 6, 2016
2 parents 303f059 + 1fb33aa commit 007e4f0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/util/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package mount
import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util/exec"
"path/filepath"
)

type Interface interface {
Expand Down Expand Up @@ -86,8 +87,13 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) {

// Find the device name.
deviceName := ""
// If mountPath is symlink, need get its target path.
slTarget, err := filepath.EvalSymlinks(mountPath)
if err != nil {
slTarget = mountPath
}
for i := range mps {
if mps[i].Path == mountPath {
if mps[i].Path == slTarget {
deviceName = mps[i].Device
break
}
Expand All @@ -99,7 +105,7 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) {
glog.Warningf("could not determine device for path: %q", mountPath)
} else {
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)
}
}
Expand All @@ -118,8 +124,13 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
// Find the device name.
// FIXME if multiple devices mounted on the same mount path, only the first one is returned
device := ""
// If mountPath is symlink, need get its target path.
slTarget, err := filepath.EvalSymlinks(mountPath)
if err != nil {
slTarget = mountPath
}
for i := range mps {
if mps[i].Path == mountPath {
if mps[i].Path == slTarget {
device = mps[i].Device
break
}
Expand Down

0 comments on commit 007e4f0

Please sign in to comment.