Skip to content

Commit

Permalink
Merge pull request kubernetes#38421 from jingxu97/automated-cherry-pi…
Browse files Browse the repository at this point in the history
…ck-of-#38411-upstream-release-1.5

Automatic merge from submit-queue

Automated cherry pick of kubernetes#38411

Cherry pick of kubernetes#38411 on release-1.5.

kubernetes#38411: Fix unmountDevice issue caused by shared mount in GCI
  • Loading branch information
Kubernetes Submit Queue authored Dec 9, 2016
2 parents 35fd136 + b4129fd commit 10c2db1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
10 changes: 1 addition & 9 deletions pkg/util/mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,13 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) {
}
}

// TODO: this is a workaround for the unmount device issue caused by gci mounter.
// In GCI cluster, if gci mounter is used for mounting, the container started by mounter
// script will cause additional mounts created in the container. Since these mounts are
// irrelavant to the original mounts, they should be not considered when checking the
// mount references. Current solution is to filter out those mount paths that contain
// the string of original mount path.
// Plan to work on better approach to solve this issue.

// Find all references to the device.
var refs []string
if deviceName == "" {
glog.Warningf("could not determine device for path: %q", mountPath)
} else {
for i := range mps {
if mps[i].Device == deviceName && !strings.Contains(mps[i].Path, slTarget) {
if mps[i].Device == deviceName && mps[i].Path != slTarget {
refs = append(refs, mps[i].Path)
}
}
Expand Down
22 changes: 21 additions & 1 deletion pkg/volume/util/operationexecutor/operation_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package operationexecutor

import (
"fmt"
"strings"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -1053,7 +1054,8 @@ func (oe *operationExecutor) generateUnmountDeviceFunc(
err)
}
refs, err := attachableVolumePlugin.GetDeviceMountRefs(deviceMountPath)
if err != nil || len(refs) > 0 {

if err != nil || hasMountRefs(deviceMountPath, refs) {
if err == nil {
err = fmt.Errorf("The device mount path %q is still mounted by other references %v", deviceMountPath, refs)
}
Expand Down Expand Up @@ -1124,6 +1126,24 @@ func (oe *operationExecutor) generateUnmountDeviceFunc(
}, nil
}

// TODO: this is a workaround for the unmount device issue caused by gci mounter.
// In GCI cluster, if gci mounter is used for mounting, the container started by mounter
// script will cause additional mounts created in the container. Since these mounts are
// irrelavant to the original mounts, they should be not considered when checking the
// mount references. Current solution is to filter out those mount paths that contain
// the string of original mount path.
// Plan to work on better approach to solve this issue.

func hasMountRefs(mountPath string, mountRefs []string) bool {
count := 0
for _, ref := range mountRefs {
if !strings.Contains(ref, mountPath) {
count = count + 1
}
}
return count > 0
}

func (oe *operationExecutor) generateVerifyControllerAttachedVolumeFunc(
volumeToMount VolumeToMount,
nodeName types.NodeName,
Expand Down

0 comments on commit 10c2db1

Please sign in to comment.