-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Kubernetes CSI - in-tree Plugin Implementation #54529
Kubernetes CSI - in-tree Plugin Implementation #54529
Conversation
/assign |
/ok-to-test |
lgtm for this stage |
|
@vladimirvivien you can use |
/hold |
@vladimirvivien Seems this PR is based on #55204. Can we close #55204? I don't like to split this feature into 2 PRs, WDYT? |
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.
It would be nice to have a separate commit with just the plugin, now it's in the same commit as the API.
pkg/volume/csi/csi_client.go
Outdated
if v.GetMajor() == ver.GetMajor() && | ||
v.GetMinor() == ver.GetMinor() && | ||
v.GetPatch() == ver.GetPatch() { | ||
supported = true |
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.
break
here?
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.
Test will only be true (if any) one time. Once true, no other condition can turn it off (which is what a break would avoid).. ok take that back.. i'll add to avoid completing loop.
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.
Cleaned
pkg/volume/csi/csi_attacher.go
Outdated
@@ -0,0 +1,62 @@ | |||
/* | |||
Copyright 2014 The Kubernetes Authors. |
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.
wrong year (applies to all new files)
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.
updated all files.
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 still see 2014. Did you push the updates?
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.
Cleaned.
pkg/volume/csi/csi_client.go
Outdated
} | ||
} | ||
if !supported { | ||
return fmt.Errorf("version %d.%d.%d not supported", ver.GetMajor(), ver.GetMinor(), ver.GetPatch()) |
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.
It would be nice to log also version(s) supported by the driver.
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.
Agreed!
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.
updated, cleaned
pkg/volume/csi/csi_client.go
Outdated
VolumeId: volId, | ||
TargetPath: targetPath, | ||
Readonly: readOnly, | ||
PublishVolumeInfo: map[string]string{"device": "/dev/null"}, //TODO where is this from |
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.
ad TODO: you get this from AttachedVolume.Status.AttachmentMetadata. For non-attachable drivers it should be IMO empty.
So, you could call ControllerGetCapabilities
to find out if the driver is attachable (once, if possible) and then do API Get request for VolumeAttachment instance - VolumeHost can give you kube client.
OTOH, doing Get with every Setup call may be too offensive... can the plugin create an informer that gets updated with events?
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.
+1 This info is in AttachedVolume.Status.AttachmentMetadata
. I would fetch and cache it at the beginning of SetupAt
if ControllerGetCapabilities
says the driver is attachable.
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.
Done. Required a few new things, but done.
{name: "test ok", volID: "vol-test", targetPath: "/test/path"}, | ||
{name: "missing volID", targetPath: "/test/path", mustFail: true}, | ||
{name: "missing target path", volID: "vol-test", mustFail: true}, | ||
{name: "bad fs", volID: "vol-test", targetPath: "/test/path", fsType: "badfs", mustFail: true}, |
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 admit I have troubles reviewing this. The test is correct, just the fake client is "far away", i.e. in a different file in a separate directory.
<pedantic>
In addition, the fake client does not check that it got correct NodePublishVolumeRequest
- it checks that the values were filled, but it does not check that the values have expected value.
</pedantic>
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.
@jsafrane the distance of the fake client was sort of necessary since it is it's own thing with lots of code. There are some validation rules in the aggregation client type, csiDriverClient
, which façades all three grpc clients. Adding more expectations would make the fake csi driver not so fake.
pkg/volume/csi/csi_mounter.go
Outdated
return err | ||
} | ||
|
||
_, volID := path.Split(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.
This implies that CSI volume IDs don't contain slashes. IMO it's very dangerous assumption.
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.
If we do proper sanitization of the name in GetPath
, as mentioned above, it should be fine. The CSI spec has also been modified to limit allowed characters (/
is not allowed).
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.
ack
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 apply slash-escape logic indicated earlier.
} | ||
|
||
// ProbeVolumePlugins returns implemented plugins | ||
func ProbeVolumePlugins() []volume.VolumePlugin { |
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.
ProbeVolumePlugins is ok for now (with hardcoded socket), but it should be called dynamically when kubelet discovers a new CSI driver on the machine. Some TODO comment would be nice.
I assume in future there will be multiple instances of csiPlugin
, one for each driver (following the Flex model).
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.
multiple instances of csiPlugin, one for each driver
Well... this is going to be very interesting. There will be multiple instances of csiPlugin, one for each driver only on nodes. Controller-manager (provisioner, a/d controller) will have one instance of the plugin for all CSI drivers - there is no way how to enumerate drivers on master.
It should work, however we need to test it carefuly.
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.
@jsafrane agreed, will add TODO. Discovery is still not clear and we definitely need to come back and careful tests. Solution can be as simple as a known path for socket (a la flexvolume) or resource registry.
pkg/volume/csi/csi_plugin.go
Outdated
} | ||
|
||
func (p *csiPlugin) CanSupport(spec *volume.Spec) bool { | ||
return spec.PersistentVolume != nil && spec.PersistentVolume.Spec.CSI != 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.
Especially this one must be different on nodes (where you should compare also Driver name) and on controllers (where presence of Spec.CSI is enough).
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.
@jsafrane so you are saying CanSupport
should take into consideration the Driver the spec is configured for? If so, agreed. I will add TODO here.
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, CanSupport
in kubelet it should check the driver, on the controller-manager it should not.
pkg/volume/csi/csi_mounter_test.go
Outdated
|
||
// Mounter.SetUp() | ||
if err := csiMounter.SetUp(nil); err != nil { | ||
t.Fatal("mounter.Setup failed: %v", err) |
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.
Fatalf
pkg/volume/csi/csi_plugin.go
Outdated
) | ||
|
||
const ( | ||
csiName = "csi" |
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.
csiName
does not seem to be used anywhere.
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 clean
/test pull-kubernetes-node-e2e |
@thockin for approval of vendored code |
[MILESTONENOTIFIER] Milestone Pull Request Current @derekwaynecarr @jsafrane @saad-ali @thockin @vladimirvivien @yifan-gu Note: If this pull request is not resolved or labeled as Pull Request Labels
|
cmd/kubelet/app/plugins.go
Outdated
@@ -96,6 +97,7 @@ func ProbeVolumePlugins() []volume.VolumePlugin { | |||
allPlugins = append(allPlugins, scaleio.ProbeVolumePlugins()...) | |||
allPlugins = append(allPlugins, local.ProbeVolumePlugins()...) | |||
allPlugins = append(allPlugins, storageos.ProbeVolumePlugins()...) | |||
allPlugins = append(allPlugins, csi.ProbeVolumePlugins()...) |
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.
Shouldn't this be alpha-gated?
Approving, you can add the feature gate. /approve |
Adding do-not-merge until flag gate is added around probe. |
This commit tracks source code update for the CSI volume plugin implementation.
This commit tracks all auto-generated sources.
/lgtm Thanks again @vladimirvivien! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mikedanese, saad-ali, thockin, vladimirvivien Associated issue: 178 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test pull-kubernetes-bazel-test |
/test all [submit-queue is verifying that this PR is safe to merge] |
@vladimirvivien: 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. |
Automatic merge from submit-queue (batch tested with PRs 54529, 53765). If you want to cherry-pick this change to another branch, please follow the instructions here. |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Kubernetes CSI - Persistent Volume Source Type **What this PR does / why we need it**: This PR is to track the addition of new API type `CSIPersistentVolumeSource` that will be used as PersistentVolume for storage sources managed by CSI drivers. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/enhancements#178 **Special notes for your reviewer**: - Implements API `PersistentVolume` type `CSIPersistentVolumeSource` - Part of implementation for kubernetes/enhancements#178 - Designed at kubernetes/community#1258 Other CSI Volume Plugin PRs: - Plugin Mounter/Unmounter kubernetes/kubernetes#54529 - Plugin Attacher/Detacher kubernetes/kubernetes#55809 **Release note**: ```release-note NONE ``` Kubernetes-commit: 928c85fc997a49e607a94960f1680d9a87b8934f
What this PR does / why we need it:
This PR is part of the internal Kubernetes CSI Volume plugin. It implements the Attach/Detach/Mount/Unmount API.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): kubernetes/enhancements#178Special notes for your reviewer:
Other CSI Volume plugin PRs
Release note: