Skip to content

Support GCEPD driver for Windows #483

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

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

jingxu97
Copy link
Contributor

@jingxu97 jingxu97 commented Mar 17, 2020

This PR adds the support for gcepd driver to work on Windows node. The
driver will call csi-proxy API to perform file, volume and disk
operations.

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Add Windows support in GCE PD driver with the use of csi-proxy (https://github.com/kubernetes-csi/csi-proxy/). 

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 17, 2020
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 17, 2020
@jingxu97 jingxu97 changed the title WIP: Support GCEPD driver for Windows Support GCEPD driver for Windows Mar 21, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 21, 2020
@jingxu97 jingxu97 force-pushed the Feb/csiproxy branch 2 times, most recently from f8d2676 to 9b72ff0 Compare March 23, 2020 17:28
@jingxu97
Copy link
Contributor Author

/test pull-gcp-compute-persistent-disk-csi-driver-e2e

@jingxu97
Copy link
Contributor Author

cc @ddebroy @kkmsft @msau42

@msau42
Copy link
Contributor

msau42 commented Mar 23, 2020

/retest

@jingxu97
Copy link
Contributor Author

/test pull-gcp-compute-persistent-disk-csi-driver-e2e

1 similar comment
@jingxu97
Copy link
Contributor Author

/test pull-gcp-compute-persistent-disk-csi-driver-e2e

@jingxu97
Copy link
Contributor Author

/test pull-gcp-compute-persistent-disk-csi-driver-e2e

1 similar comment
@jingxu97
Copy link
Contributor Author

/test pull-gcp-compute-persistent-disk-csi-driver-e2e

@jingxu97 jingxu97 force-pushed the Feb/csiproxy branch 5 times, most recently from e7aa0f2 to c8c2d8b Compare March 26, 2020 18:57
@jingxu97
Copy link
Contributor Author

/test pull-gcp-compute-persistent-disk-csi-driver-kubernetes-integration

@jingxu97
Copy link
Contributor Author

cc @saad-ali @msau42

@verult
Copy link
Contributor

verult commented Mar 31, 2020

/cc

@k8s-ci-robot k8s-ci-robot requested a review from verult March 31, 2020 01:48
Copy link
Contributor

@verult verult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass, need to review the rest of safe-mounter_windows.go

limitations under the License.
*/

package gceGCEDriver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: definitely out of scope for this PR, but the convention is to avoid mixCaps: https://golang.org/doc/effective_go.html#package-names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. we can do another PR for it.

"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
)

func GetDevicePath(ns *GCENodeServer, volumeID, partition string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all functions here have the same casing for the first letter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

return false, nil
}

//TODO: implement StatFS to get metrics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: include username or issue #

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return err
}
if exists {
return proxy.Unmount(path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Linux we reuse the path if it already exists. Why don't we unmount there?

Copy link
Contributor Author

@jingxu97 jingxu97 Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for windows, before mounting (which is creating symlink), the dir should not exist. Only the parent dir should be created. Now in kubelet, it creates this dir beforehand, so this is a workaround to remove the dir first.
Added some comments for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason when I reviewed, I didn't see Cheng's comments and asked the same thing :-)

What if the volume is actually mounted? In that case, I don't think we should do an entire Unmount if it's already done.

Another confusing piece here is that the behavior we want is really "rmdir", but we're calling an api called "unmount".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If volume is actually mounted, it should not call this function and return immediately
https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/483/files#diff-37c748634a23b1ed91abeaa8a6d21525R108

in windows, actually unmount and rmdir is the same thing. Mount is to create a symlink, and unmount is to delete this link.
I rename the functions on this and related part. Please let me know if there is any issue.

}, nil
}

func (mounter *CSIProxyMounter) Mount(source string, target string, fstype string, options []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this called anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in node.go line 172

go.mod Outdated
gopkg.in/gcfg.v1 v1.2.3
gopkg.in/warnings.v0 v0.1.2 // indirect
k8s.io/apimachinery v0.17.1
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.14.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this dependency for? the apimachinery dependency is on 1.17 so having this on 1.14 may cause strange problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it. not sure how it was added.

@@ -316,7 +326,8 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
return &csi.NodeStageVolumeResponse{}, nil
}

err = ns.Mounter.FormatAndMount(devicePath, stagingTargetPath, fstype, options)
//err = ns.Mounter.FormatAndMount(devicePath, stagingTargetPath, fstype, options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

return err
}
if exists {
return proxy.Unmount(path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to unmount if it's already mounted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment. actually it is to remove the dir, not a real unmount like linux. I think could change the name if it is more clear.

// Call the LinkPath CSI proxy from the source path to the target path
parentDir := filepath.Dir(target)
if _, err := os.Stat(target); !os.IsNotExist(err) {
os.RemoveAll(target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we try to avoid calling RemoveAll because we had cases in the past where the volume was still mounted, and RemoveAll ended up deleting user data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, it is removed because preparePublishPath did it

return nil
}

func normalizeWindowsPath(path string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some unit tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually mount utility already has the exact function and has unit test for it. I replace it with mount utitliy's one.

go.mod Outdated
github.com/google/uuid v1.1.1
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/kubernetes-csi/csi-proxy/client v0.0.0-20200319061913-d6ab31300107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually use the real tag version, but we need add a special tag to the csi-proxy repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will work on it.

@jingxu97
Copy link
Contributor Author

jingxu97 commented Apr 1, 2020

I tried to addressed most the comments, working on adding unit test.

@jingxu97 jingxu97 force-pushed the Feb/csiproxy branch 2 times, most recently from 24c7280 to fb989b6 Compare April 1, 2020 20:22
@jingxu97
Copy link
Contributor Author

jingxu97 commented Apr 1, 2020

@verult @msau42 I think all comments were addressed. PTAL. Thanks!

@msau42
Copy link
Contributor

msau42 commented Apr 1, 2020

/lgtm
/approve
Can you add a release note?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 1, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jingxu97, msau42

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 1, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 2, 2020
Copy link
Contributor

@verult verult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Minor nits

Could you also add your GitHub handle to the remaining TODOs (also a nit :) )?

if err != nil {
return err
}
// TODO: Check if the volume is formatted by calling IsVolumeFormatted CSI proxy call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still apply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not needed. removed it.


}

// formatAndMount - accepts the source disk number, target path to mount, the fstype to format with and options to be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you mention that it mounts to the host?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 2, 2020
This PR adds the support for gcepd driver to work on Windows node. The
driver will call csi-proxy API to perform file, volume and disk
operations.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 3, 2020
@jingxu97
Copy link
Contributor Author

jingxu97 commented Apr 3, 2020

@msau42 @verult I added release note, and update the PR. Could you please give /lgtm? Thanks!

@msau42
Copy link
Contributor

msau42 commented Apr 3, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 3, 2020
@k8s-ci-robot k8s-ci-robot merged commit c83c131 into kubernetes-sigs:master Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants