-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
persistent and ephemeral csi volumes #79983
persistent and ephemeral csi volumes #79983
Conversation
/assign @vladimirvivien |
/sig storage |
pkg/volume/csi/csi_mounter.go
Outdated
@@ -60,7 +61,7 @@ type csiMountMgr struct { | |||
k8s kubernetes.Interface | |||
plugin *csiPlugin | |||
driverName csiDriverName | |||
driverMode driverMode | |||
volumeMode volumeMode |
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 volumeMode
would be misleading or confused with pv.spec.volumeMode
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, naming is hard 😦
I also considered ephemeralMode
or inlineMode
, but both then don't make much sense when the value is persistent
.
Any suggestions?
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.
How about VolumeSource
, with persistent
and ephemeral
as values?
It's then different from driverMode
, but perhaps that's okay.
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.
Yeah, naming things is hard. Slight preference to the previous name, driverMode, as that kind of matches the spec:
CSIDriver.Spec.Mode -> driverMode.
Or maybe csiDriverMode?
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.
VolumeSource
also could be misunderstood (see snapshotting...). Let's see how well CSIVolumeMode
works...
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.
Works for me.
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 left "driverMode" unchanged, because as you said, it is derived from CSIDriver.Spec.Mode
.
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.
With my limited knowledge of how e2e works, and excluding the naming question, this all looks good to me. :)
80b6fe7
to
fc451cb
Compare
pkg/volume/csi/csi_plugin.go
Outdated
if csiVolumeMode == ephemeralVolumeMode { | ||
klog.V(5).Info(log("plugin.CanDeviceMount skipped ephemeral mode detected for spec %v", spec.Name())) | ||
return false, 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.
Would this make it more clear?
If you do not think so, ignore it.
if !inlineEnabled {
return true, nil
}
driverMode, err := p.getDriverMode(spec)
...
return true, 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.
Yes, I think that's better and more consistent with usual Go style. I changed it, please have another look.
fc451cb
to
a32af6b
Compare
/retest |
@cwdsuzhou is it okay now? |
pkg/volume/csi/csi_mounter.go
Outdated
@@ -323,6 +324,7 @@ func (c *csiMountMgr) podAttributes() (map[string]string, error) { | |||
"csi.storage.k8s.io/pod.namespace": c.pod.Namespace, | |||
"csi.storage.k8s.io/pod.uid": string(c.pod.UID), | |||
"csi.storage.k8s.io/serviceAccount.name": c.pod.Spec.ServiceAccountName, | |||
"csi.storage.k8s.io/ephemeral": strconv.FormatBool(c.csiVolumeMode == ephemeralVolumeMode), |
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.
@kfox1111 should the presence of this new field in the PodInfo depend on the feature gate?
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.
Hmm... That is a good question...
It shouldn't hurt anything to have it always defined as it is, but following the principal that nothing should change if the gate is disabled, it probably should be behind the gate, yeah.
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've made it optional, i.e. it only gets added when the feature gate is set.
func InitEphemeralTestSuite() TestSuite { | ||
return &ephemeralTestSuite{ | ||
tsInfo: TestSuiteInfo{ | ||
name: "ephemeral", |
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.
/hold
Currently ephemeral inline volumes are an alpha feature, so this whole suite must have a [Feature:CSIInlineVolume]
tag. Will add it.
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.
/hold cancel |
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.
These consts should be defined in the api. If the API is not there yet, then we should remember to remove these once we add it
The API still needs to be added. I've done that in a follow-up branch and also moved the constants.
@@ -44,6 +44,8 @@ var ( | |||
PreprovisionedPV TestVolType = "PreprovisionedPV" | |||
// DynamicPV represents a volume type for dynamic provisioned Persistent Volume | |||
DynamicPV TestVolType = "DynamicPV" | |||
// CSIVolume represents a volume type that is defined inline and provided by a CSI driver. | |||
CSIVolume TestVolType = "CSIVolume" |
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 can rename "CSIVolume" to "CSIInlineVolume". I chose "CSIVolume" because that's also the term used in "CSIVolumeSource" (
kubernetes/staging/src/k8s.io/api/core/v1/types.go
Lines 1706 to 1707 in 1dac5fd
// Represents a source location of a volume to mount, managed by an external CSI driver | |
type CSIVolumeSource struct { |
The reason for the separate volume type is, as you said, that the characteristics of the volume are different. I don't know whether it makes a difference in practice, though.
aa8999a
to
564e628
Compare
/retest |
564e628
to
dc5ecfa
Compare
/retest |
dc5ecfa
to
93a0afe
Compare
I included another fix (problem found while enabling in-tree testing of ephemeral volumes with the CSI hostpath driver):
It worked when testing an external driver because the unique name is the same as the base name... |
And using the generated name breaks testing an external driver... this needs some more work before it works for both. /hold |
Fixed this way:
The removal of |
93a0afe
to
817a43d
Compare
/hold cancel |
For reference, the in-tree usage of the new ephemeral testsuite test is part of PR #80568, currently in commit 4de69dcf9e759c9f096f83d0a444a3e091342f73. |
The name was meant to be used as shorter replacement for potentially long CSI driver names, but was never used in practice.
The conceptual change is that the mode in which a volume gets handled is derived from it's spec, not from the ability of the driver. In practice, that is already how the code worked because it didn't actually look at CSIDriver.Spec.Mode at all. Therefore the code change itself is mostly just renaming "driver mode" to "volume mode". In some places (CanDeviceMount, CanAttach) the feature check that was used elsewhere seemed to be missing. Now their code path for ephemeral volumes are also only entered if that feature is enabled. The sanity check whether a CSI driver is being used correctly still needs to be implemented. Related-to: kubernetes#79624
The PodInfo tests can be extended to also cover the new csi.storage.k8s.io/ephemeral flag. However, the presence of that flag depends on whether inline volume support is enabled, so tests that run with and without the feature have to detect that at runtime. Other tests have a feature tag and thus can assume that they only run when that feature is enabled. However, we need a newer csi-mock driver before we can actually ask it to publish an ephemeral inline volume.
817a43d
to
4bc5d06
Compare
/test pull-kubernetes-integration |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: msau42, pohly 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This is part of the effort to move CSI inline ephemeral volumes to beta.
Which issue(s) this PR fixes:
Related-to: #79624
Does this PR introduce a user-facing change?: