-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Conversation
pkg/util/mount/mount_windows.go
Outdated
for _, ref := range refs { | ||
if strings.Contains(ref, basemountPath) { | ||
volumeID, err := filepath.Rel(normalizeWindowsPath(basemountPath), ref) | ||
if strings.Contains(ref, pluginDir) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
pkg/volume/awsebs/aws_ebs.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/util/mount/mount_linux.go
Outdated
if strings.HasPrefix(ref, basemountPath) { | ||
volumeID, err := filepath.Rel(basemountPath, ref) | ||
if strings.HasPrefix(ref, pluginDir) { | ||
volumeID, err := filepath.Rel(pluginDir, ref) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 😆
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 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. |
78d77ae
to
008d789
Compare
@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 |
/test pull-kubernetes-e2e-gce |
008d789
to
e05b8a7
Compare
/test pull-kubernetes-bazel-test |
/lgtm @andyzhangx @jingxu97 would you be able to help test this change on windows? Especially the configmap/secret/emptydir/projected/atomic writer changes? |
e05b8a7
to
0780ddc
Compare
cc @yujuhong
|
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 |
/approve |
[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 |
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.
4faface
to
78d109e
Compare
/test pull-kubernetes-bazel-test |
/test pull-kubernetes-e2e-windows-gce |
1 similar comment
/test pull-kubernetes-e2e-windows-gce |
/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 |
/test pull-kubernetes-e2e-windows-gce |
@yujuhong Hijack away, and good luck. =) |
I doubt it is helpful, but the main thing that jumps out to me from the logs to me is the linux reference, here:
For a windows test, that raises red flags for me. |
/test pull-kubernetes-e2e-windows-gce |
We need to build both windows and linux artifacts since the master control plane runs only on linux :-) |
@codenrhoden: The following test failed, say
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. |
Anything I can do to move this along? |
windows pull job still needs a bit of work to get passing |
/lgtm |
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... |
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 constantthat 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 volumepluginDir 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?: