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 check for subpath source #105512
Fix check for subpath source #105512
Conversation
/sig storage |
/kind bug |
1b13067
to
c2cf45e
Compare
(volumeMountInfo.Major == mntInfo.Major && volumeMountInfo.Minor == mntInfo.Minor) { | ||
klog.V(5).Infof("Skipping bind-mounting subpath %s, volumePath: %s, path: %s", bindPathTarget, subpath.VolumePath, subpath.Path) | ||
return true, bindPathTarget, nil | ||
} |
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.
Here the error is ignored because of ConfigMaps?
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 think this could use a comment to explain the reason to exempt these subpath bind mounts from the Unmount
call below. IIUC, the configmap and secret subpaths should still trigger unmount, but bind mounts should not?
Does mount.PathWithinBase(subpath.Path, subpath.VolumePath)
only return true for bind mounts then?
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.
Would it be feasible to add a unit test for this path?
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 have changed this logic to hardcode just the volume types that will trigger unmount and mount. I think apart from that every other volume type should use previously mounted subpath bind mount.
/retest |
@@ -164,6 +164,28 @@ func (hu *HostUtil) FindMountInfo(path string) (mount.MountInfo, error) { | |||
return findMountInfo(path, procMountInfoPath) | |||
} | |||
|
|||
// FindExactMountInfo returns exact mount point that matches given path |
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.
maybe add more details about the difference between FindMountInfo and FindExactMountInfo?
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 removed this function. I think the only volume types that really need to trigger mount and unmount is intree ephemeral types.
/assigne @fatedier |
ad66bc7
to
f68c948
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gnufied 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 |
@msau42 @jsafrane I have updated the code to use |
f68c948
to
e3d5b31
Compare
}, | ||
} | ||
for _, test := range tests { | ||
klog.V(4).Infof("test %q", test.name) |
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.
Just a suggestion for temp dirs + defer for os.RemoveAll
t.Run(test.name, func (t *testing.T){
base, err = ioutil.TempDir()
if err {...}
defer os.RemoveAll(base)
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.
fixed.
e3d5b31
to
467bcd8
Compare
lgtm. Giving @msau42 a chance to review. |
/hold cancel |
/lgtm |
done. |
Unrelated failure:
/retest |
…512-upstream-release-1.22 Automated cherry pick of #105512: Add check for subpaths
…512-upstream-release-1.21 Automated cherry pick of #105512: Add check for subpaths
…512-upstream-release-1.20 Automated cherry pick of #105512: Add check for subpaths
Fix #105472
I have verified that this fixes CSI/NFS and other volume types and at the same time it keeps older behaviour for configmaps/secrets etc. This code relies on the fact that most volume types create a mount point in
/var/lib/kubelet/pods/xxxx/volumes/
when being mounted. The check here won't work for volume types that don't create mount point for main volume (but it is not a regression, at least). For configmaps etc - no bind mount is created unless user specifies subpaths.For NFS volume with fix: