Skip to content

Commit

Permalink
Fix windows NodePublish failing because mount target doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
wongma7 committed Oct 6, 2021
1 parent 869e7f5 commit 27215b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/kubernetes/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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, "Error checking if %q is mounted: %v", target, err)
}

if !mounted {
Expand Down

0 comments on commit 27215b0

Please sign in to comment.