Skip to content

Commit bcc66c4

Browse files
committed
Switched unmounting to more robust kubernetes volumeutils verison
1 parent 5181cdc commit bcc66c4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
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"
@@ -139,9 +140,7 @@ func (ns *GCENodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeU
139140
return nil, status.Error(codes.InvalidArgument, "NodeUnpublishVolume Target Path must be provided")
140141
}
141142

142-
// TODO(#96): Check volume still exists
143-
144-
err := ns.Mounter.Interface.Unmount(targetPath)
143+
err := volumeutils.UnmountMountPoint(targetPath, ns.Mounter.Interface, false /* bind mount */)
145144
if err != nil {
146145
return nil, status.Error(codes.Internal, fmt.Sprintf("Unmount failed: %v\nUnmounting arguments: %s\n", err, targetPath))
147146
}
@@ -259,7 +258,7 @@ func (ns *GCENodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUns
259258
return nil, status.Error(codes.InvalidArgument, "NodeUnstageVolume Staging Target Path must be provided")
260259
}
261260

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

0 commit comments

Comments
 (0)