Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows NodePublish failing because mount target doesn't exist #1081

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix windows NodePublish failing because mount target doesn't exist
wongma7 committed Oct 6, 2021
commit a8ae3631f662020d0fabd8e6df762d3e13218edc
2 changes: 1 addition & 1 deletion examples/kubernetes/windows/README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ This example shows how to create a EBS volume and consume it from a Windows cont

1. A 1.18+ Windows node. Windows support has only been tested on 1.18 EKS Windows nodes. https://docs.aws.amazon.com/eks/latest/userguide/windows-support.html
2. [csi-proxy](https://github.com/kubernetes-csi/csi-proxy) v1.0.0+ installed on the Windows node.
3. Driver v1.3.0 from GCR k8s.gcr.io/provider-aws/aws-ebs-csi-driver:v1.3.0. It can be built and pushed to another image registry with the command `TAG=$MY_TAG REGISTRY=$MY_REGISTRY make all-push` where `MY_TAG` refers to the image tag to push and `MY_REGISTRY` to the destination image registry like "XXXXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com"
3. Driver v1.3.2 from GCR k8s.gcr.io/provider-aws/aws-ebs-csi-driver:v1.3.2. It can be built and pushed to another image registry with the command `TAG=$MY_TAG REGISTRY=$MY_REGISTRY make all-push` where `MY_TAG` refers to the image tag to push and `MY_REGISTRY` to the destination image registry like "XXXXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com"
4. The driver installed with the Node plugin on the Windows node and the Controller plugin on a Linux node: `helm upgrade --install aws-ebs-csi-driver --namespace kube-system ./charts/aws-ebs-csi-driver --set node.enableWindows=true --set image.repository=$MY_REGISTRY/aws-ebs-csi-driver --set image.tag=$MY_TAG`

## Usage
13 changes: 9 additions & 4 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
@@ -589,7 +589,7 @@ func (d *nodeService) nodePublishVolumeForBlock(req *csi.NodePublishVolumeReques
//Checking if the target file is already mounted with a device.
mounted, err := d.isMounted(source, target)
if err != nil {
return status.Errorf(codes.Internal, "Could not mount %q at %q: %v", source, target, err)
return status.Errorf(codes.Internal, "Could not check if %q is mounted: %v", target, err)
}

if !mounted {
@@ -626,15 +626,20 @@ func (d *nodeService) isMounted(source string, target string) (bool, error) {
//After successful unmount, the device is ready to be mounted.
return !notMnt, nil
}
return !notMnt, status.Errorf(codes.Internal, "Could not mount %q at %q: %v", source, target, err)
return !notMnt, status.Errorf(codes.Internal, "Could not check if %q is a mount point: %v, %v", target, err, pathErr)
}

if !notMnt {
klog.V(4).Infof("NodePublishVolume: Target path %q is already mounted", target)
return !notMnt, nil
}

return !notMnt, err
// Do not return os.IsNotExist error. Other errors were handled above. It is
// the responsibility of the caller to check whether the given target path
// exists (in Linux, the target mount directory must exist before mount is
// called on it) or not (in Windows, the target must NOT exist before a
// symlink is created at it)
return !notMnt, nil
}

func (d *nodeService) nodePublishVolumeForFileSystem(req *csi.NodePublishVolumeRequest, mountOptions []string, mode *csi.VolumeCapability_Mount) error {
@@ -665,7 +670,7 @@ func (d *nodeService) nodePublishVolumeForFileSystem(req *csi.NodePublishVolumeR
mounted, err := d.isMounted(source, target)

if err != nil {
return status.Errorf(codes.Internal, "Could not mount %q at %q: %v", source, target, err)
return status.Errorf(codes.Internal, "Could not check if %q is mounted: %v", target, err)
}

if !mounted {