Skip to content

Commit c9b4546

Browse files
committed
Switched unmounting to more robust kubernetes volumeutils verison
1 parent d69d75e commit c9b4546

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pkg/gce-pd-csi-driver/node.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"google.golang.org/grpc/codes"
2727
"google.golang.org/grpc/status"
2828
"k8s.io/kubernetes/pkg/util/mount"
29+
volumeutils "k8s.io/kubernetes/pkg/volume/util"
2930
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
3031
metadataservice "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/metadata"
3132
mountmanager "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/mount-manager"
@@ -66,7 +67,7 @@ func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePub
6667
return nil, status.Error(codes.InvalidArgument, "NodePublishVolume Volume Capability must be provided")
6768
}
6869

69-
notMnt, err := ns.Mounter.Interface.IsLikelyNotMountPoint(targetPath)
70+
notMnt, err := ns.Mounter.Interface.IsNotMountPoint(targetPath)
7071
if err != nil && !os.IsNotExist(err) {
7172
glog.Errorf("cannot validate mount point: %s %v", targetPath, err)
7273
return nil, err
@@ -133,9 +134,7 @@ func (ns *GCENodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeU
133134
return nil, status.Error(codes.InvalidArgument, "NodeUnpublishVolume Target Path must be provided")
134135
}
135136

136-
// TODO(#96): Check volume still exists
137-
138-
err := ns.Mounter.Interface.Unmount(targetPath)
137+
err := volumeutils.UnmountMountPoint(targetPath, ns.Mounter.Interface, true /* bind mount */)
139138
if err != nil {
140139
return nil, status.Error(codes.Internal, fmt.Sprintf("Unmount failed: %v\nUnmounting arguments: %s\n", err, targetPath))
141140
}
@@ -242,7 +241,7 @@ func (ns *GCENodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUns
242241
return nil, status.Error(codes.InvalidArgument, "NodeUnstageVolume Staging Target Path must be provided")
243242
}
244243

245-
err := ns.Mounter.Interface.Unmount(stagingTargetPath)
244+
err := volumeutils.UnmountMountPoint(stagingTargetPath, ns.Mounter.Interface, false /* bind mount */)
246245
if err != nil {
247246
return nil, status.Error(codes.Internal, fmt.Sprintf("NodeUnstageVolume failed to unmount at path %s: %v", stagingTargetPath, err))
248247
}

0 commit comments

Comments
 (0)