-
Notifications
You must be signed in to change notification settings - Fork 61
Add GetClosestVolumeIDFromTargetPath API to the Volume API Group #185
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
Add GetClosestVolumeIDFromTargetPath API to the Volume API Group #185
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mauriciopoppe The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
beb68cf
to
40a345c
Compare
40a345c
to
e2588fa
Compare
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.
Recommend starting a v2beta1 API group in volume for the new changes.
return "", err | ||
} | ||
// if it has the form Volume{volumeid}\ then it's a volume | ||
if strings.HasPrefix(target, "Volume") { |
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.
Will it be possible to make this a more rigorous check? For example, a regex to match the Volume{volumeID} pattern rather than a prefix and also checking with Get-Volume
when the regex matches.
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.
@jingxu97 shared some code from k/k that uses this function: https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/util/subpath/subpath_windows.go#L62:6, what I saw is that after dereferencing a symlink it had the form: Volume{X}
or C:/foo/bar
// GetClosestVolumeIDFromTargetPath gets the closest volume id for a given target path | ||
// by following symlinks and moving up in the filesystem, if after moving up in the filesystem | ||
// we get to a DriveLetter then the volume corresponding to this drive letter is returned instead. | ||
rpc GetClosestVolumeIDFromTargetPath(GetClosestVolumeIDFromTargetPathRequest) returns (GetClosestVolumeIDFromTargetPathResponse) {} |
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.
Will it be possible to start a v2beta1 API to incorporate the new set of APIs?
I think you are implementing same or similar function of evalSymlink here https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/util/subpath/subpath_windows.go#L92 |
@jingxu97 I see, it's very similar, I think that with these lines:
If the path is |
/close #189 implements the same on top of the new v2alpha1 version of the Volume API |
@mauriciopoppe: Closed this PR. In response to this:
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. |
What type of PR is this?
/kind api-change
/kind feature
What this PR does / why we need it:
Adds the new Volume API,
GetClosestVolumeIDFromTargetPath
, it allows getting the closest volume from a target path handling more scenarios as described below.The algorithm is:
Volume{
then its a volume, return itIn the following example all the calls to
GetClosestVolumeIDFromTargetPath
are with paths inside/mnt/disks
:Does this PR introduce a user-facing change?:
/cc @jingxu97 @ddebroy @msau42