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

Move MountsInGlobalPDPath from mount pkg to volume #74734

Merged
merged 2 commits into from
May 2, 2019

Conversation

codenrhoden
Copy link
Contributor

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Since pkg/util/mount is going to move out of k/k, this exported constant
that is Kubernetes specific needs to move somewhere else. Made sense to
move it to pkg/volume/util.

For the volume plugins that call mounter.GetDeviceNameFromMount(),
rather than changing the signature of mounter.GetDeviceNameFromMount()
just have the volume plugins append MountsInGlobalPDPath to the volume
pluginDir themselves rather than having mounter.GetDeviceNameFromMount()
do it since that code no longer has access to that constant.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
This is another step in making #68513 be a lot simpler.

This PR does not attempt to address #74548 at all, just maintain current functionality.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 28, 2019
@codenrhoden
Copy link
Contributor Author

/sig storage
/assign @msau42 @saad-ali

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 28, 2019
for _, ref := range refs {
if strings.Contains(ref, basemountPath) {
volumeID, err := filepath.Rel(normalizeWindowsPath(basemountPath), ref)
if strings.Contains(ref, pluginDir) {
Copy link
Member

Choose a reason for hiding this comment

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

does plugindir need to be normalized first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does. Good catch.

@@ -250,7 +250,7 @@ func getVolumeSource(

func (plugin *awsElasticBlockStorePlugin) ConstructVolumeSpec(volName, mountPath string) (*volume.Spec, error) {
mounter := plugin.host.GetMounter(plugin.GetPluginName())
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
pluginDir := filepath.Join(plugin.host.GetPluginDir(plugin.GetPluginName()), util.MountsInGlobalPDPath)
Copy link
Member

Choose a reason for hiding this comment

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

does it seem like enough plugins use this to warrant some new "GetPluginMountDir" interface?

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'm not sure it would need to be an interface, rather just an exported function perhaps in pkg/volume/util?

func GetPluginMountDir(host volume.VolumeHost, name string) string {
    pluginDir := filepath.Join(host.GetPluginDir(name), MountsInGlobalPDPath)
    return pluginDir
}

Something like that?

Copy link
Member

Choose a reason for hiding this comment

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

This sounds reasonable to me

pkg/volume/azure_dd/azure_common.go Show resolved Hide resolved
if strings.HasPrefix(ref, basemountPath) {
volumeID, err := filepath.Rel(basemountPath, ref)
if strings.HasPrefix(ref, pluginDir) {
volumeID, err := filepath.Rel(pluginDir, ref)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like pluginDir, that comes from the plugin's ConstructVolumeSpec, is no longer only the plugin directory. Now it has the MountsInGlobalPDPath const appended to it, right?

We might have to change the mount.Interface as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was what I was going for here, yes. I was trying to make as few changes as possible, without having to change mount.Interface.

An alternative would be to go ahead and change the interface from:

GetDeviceNameFromMount(mountPath, pluginDir string)

to

GetDeviceNameFromMount(mountPath, pluginDir, mountDir string)

And then append the mount dir in the function, which is what it did before.

The overall goal here is not have anything in pkg/util/mount depend on access to that constant, which needs to live in another package (I had put it in pkg/volume/util).

I'm fine with either method.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer changing it to the first

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I wasn't very clear. I preferred only having two arguments to GetDeviceNameFromMount, and having some helper method that appends the constant to the plugin dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doh. okay, I can do that. 😆

@codenrhoden
Copy link
Contributor Author

@msau42 @bertinatto

Thanks for the reviews, and apologies for the slow response. Both of my kids have been sick this week, so I've been unable to come back to this.

If I have any chance of getting this in before code freeze, I'd like to try for that.

I think the main question is whether or not to keep mount.Interface the way it is now, which requires callers of mounter.GetDeviceNameFromMount() to append the mountDir constant themselves before the call (which could be done with a common function), or to change the interface to take the mountDir as a third parameter.

I don't have a preference one way or the other. I had leaned the way I did because I didn't want to change the interface if I could avoid it in this PR.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 9, 2019
pkg/volume/photon_pd/photon_pd.go Outdated Show resolved Hide resolved
pkg/volume/storageos/storageos.go Outdated Show resolved Hide resolved
pkg/volume/rbd/rbd_util.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 29, 2019
@codenrhoden
Copy link
Contributor Author

@msau42 Okay, I went ahead and did this again after changing the interface. That commit is probably a bit easier to review now.

I ran with @andyzhangx's guidance to always use filepath.Join, and went ahead and cleaned up all usage in pkg/util/mount and pkg/util/volume in a second/separate commit.

@codenrhoden
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

@codenrhoden
Copy link
Contributor Author

/test pull-kubernetes-bazel-test

@msau42
Copy link
Member

msau42 commented Apr 3, 2019

/lgtm

@andyzhangx @jingxu97 would you be able to help test this change on windows? Especially the configmap/secret/emptydir/projected/atomic writer changes?

@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, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 9, 2019
@msau42
Copy link
Member

msau42 commented Apr 25, 2019

cc @yujuhong

Run: ('kubetest', '--dump=/logs/artifacts', '--gcp-service-account=/etc/service-account/service-account.json', '--build=gce-windows-bazel', '--up', '--down', '--provider=gce', '--cluster=e2e-cfe9c0aea2-95646', '--gcp-network=e2e-cfe9c0aea2-95646', '--check-leaked-resources', '--extract=local', '--gcp-zone=us-west1-b', '--ginkgo-parallel=8', '--gcp-nodes=2', '--test-cmd=$GOPATH/src/k8s.io/gce-k8s-windows-testing/run-e2e.sh', '--test-cmd-args=--ginkgo.focus=\\[Conformance\\]|\\[NodeConformance\\]|\\[sig-windows\\] --ginkgo.skip=\\[LinuxOnly\\]|\\[Serial\\]|\\[Feature:.+\\] --minStartupPods=8', '--test-cmd-args=--node-os-distro=windows', '--timeout=120m')
2019/04/25 16:15:55 main.go:275: Flag parse failed: invalid argument "gce-windows-bazel" for "--build" flag: bad build strategy: gce-windows-bazel (use: bazel, e2e, host-go, quick, release)

@codenrhoden
Copy link
Contributor Author

Thanks @msau42, you beat me to it. Whatever the test is, the test is broken. =)

@yujuhong
Copy link
Contributor

Thanks @msau42, you beat me to it. Whatever the test is, the test is broken. =)

The test requires a new kubetest image to pick up the change adding the flag. I filed an issue in test-infra to build and push a new image: kubernetes/test-infra#12340

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 26, 2019
@jsafrane
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: codenrhoden, jsafrane

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 29, 2019
Since pkg/util/mount is going to move out of k/k, this exported constant
that is Kubernetes specific needed to move somewhere else. Made sense to
move it to pkg/volume/util.

Update GetDeviceNameFromMount in the mount interface to now take a
pluginMountDir argument, which is volume plugin dir with the global
mount path appended to it already.
This patch cleans up pkg/util/mount/* and pkg/util/volume/* to always
use filepath.Join instead of path.Join. filepath.Join is preferred
because path.Join can have issues on Windows.
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 29, 2019
@codenrhoden
Copy link
Contributor Author

/test pull-kubernetes-bazel-test

@yujuhong
Copy link
Contributor

/test pull-kubernetes-e2e-windows-gce

1 similar comment
@codenrhoden
Copy link
Contributor Author

/test pull-kubernetes-e2e-windows-gce

@yujuhong
Copy link
Contributor

/test pull-kubernetes-e2e-windows-gce

We are trying to get the test job working, so I'm hijacking this PR to run some tests

@yujuhong
Copy link
Contributor

/test pull-kubernetes-e2e-windows-gce

@codenrhoden
Copy link
Contributor Author

@yujuhong Hijack away, and good luck. =)

@codenrhoden
Copy link
Contributor Author

I doubt it is helpful, but the main thing that jumps out to me from the logs to me is the linux reference, here:

--config=cross:linux_amd64

For a windows test, that raises red flags for me.

@yujuhong
Copy link
Contributor

/test pull-kubernetes-e2e-windows-gce

@yujuhong
Copy link
Contributor

For a windows test, that raises red flags for me.

We need to build both windows and linux artifacts since the master control plane runs only on linux :-)

@k8s-ci-robot
Copy link
Contributor

@codenrhoden: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-windows-gce 78d109e link /test pull-kubernetes-e2e-windows-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@codenrhoden
Copy link
Contributor Author

Anything I can do to move this along?

@msau42
Copy link
Member

msau42 commented May 1, 2019

windows pull job still needs a bit of work to get passing
/skip

@msau42
Copy link
Member

msau42 commented May 1, 2019

/lgtm

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

yujuhong commented May 1, 2019

windows pull job still needs a bit of work to get passing

It's not required, so you can safely ignore it.

Our build/stage process have poor support of handling multiple platforms simultaneously. I made some progress for building them, but more changes are needed for staging...

@k8s-ci-robot k8s-ci-robot merged commit b5c34d0 into kubernetes:master May 2, 2019
@codenrhoden codenrhoden deleted the move-mountspath branch May 2, 2019 00:29
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. area/code-organization Issues or PRs related to kubernetes code organization cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. 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.

None yet

10 participants