Commit f1995ad8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #38411 from jingxu97/Dec/fixgluster

Automatic merge from submit-queue Fix unmountDevice issue caused by shared mount in GCI This is a fix on top #38124. In this fix, we move the logic to filter out shared mount references into operation_executor's UnmountDevice function to avoid this part is being used by other types volumes such as rdb, azure etc. This filter function should be only needed during unmount device for GCI image.
parents 30d57bdf bb8b54af
...@@ -130,21 +130,13 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) { ...@@ -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. // Find all references to the device.
var refs []string var refs []string
if deviceName == "" { if deviceName == "" {
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 && !strings.Contains(mps[i].Path, slTarget) { if mps[i].Device == deviceName && mps[i].Path != slTarget {
refs = append(refs, mps[i].Path) refs = append(refs, mps[i].Path)
} }
} }
......
...@@ -22,6 +22,7 @@ package operationexecutor ...@@ -22,6 +22,7 @@ package operationexecutor
import ( import (
"fmt" "fmt"
"strings"
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
...@@ -1053,7 +1054,8 @@ func (oe *operationExecutor) generateUnmountDeviceFunc( ...@@ -1053,7 +1054,8 @@ func (oe *operationExecutor) generateUnmountDeviceFunc(
err) err)
} }
refs, err := attachableVolumePlugin.GetDeviceMountRefs(deviceMountPath) refs, err := attachableVolumePlugin.GetDeviceMountRefs(deviceMountPath)
if err != nil || len(refs) > 0 {
if err != nil || hasMountRefs(deviceMountPath, refs) {
if err == nil { if err == nil {
err = fmt.Errorf("The device mount path %q is still mounted by other references %v", deviceMountPath, refs) err = fmt.Errorf("The device mount path %q is still mounted by other references %v", deviceMountPath, refs)
} }
...@@ -1124,6 +1126,24 @@ func (oe *operationExecutor) generateUnmountDeviceFunc( ...@@ -1124,6 +1126,24 @@ func (oe *operationExecutor) generateUnmountDeviceFunc(
}, nil }, 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( func (oe *operationExecutor) generateVerifyControllerAttachedVolumeFunc(
volumeToMount VolumeToMount, volumeToMount VolumeToMount,
nodeName types.NodeName, nodeName types.NodeName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment