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
CSIDriver: allow "StorageCapacity" to be modified #101789
Conversation
@pohly: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
/assign @msau42 |
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.
Regarding safety of relaxing the mutability of this check:
- There are no system or csi controllers that create/update/delete this object
- The scheduler looks up the cached informer object every time
- There are no other consumers of this field
@@ -430,7 +430,6 @@ func ValidateCSIDriverUpdate(new, old *storage.CSIDriver) field.ErrorList { | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.FSGroupPolicy, old.Spec.FSGroupPolicy, field.NewPath("spec", "fsGroupPolicy"))...) | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.PodInfoOnMount, old.Spec.PodInfoOnMount, field.NewPath("spec", "podInfoOnMount"))...) | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.VolumeLifecycleModes, old.Spec.VolumeLifecycleModes, field.NewPath("spec", "volumeLifecycleModes"))...) | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.StorageCapacity, old.Spec.StorageCapacity, field.NewPath("spec", "storageCapacity"))...) |
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.
The comment in types.go should also be updated: https://github.com/kubernetes/kubernetes/blob/1f8b098e5af29392f1cb9af808a8bf915877b67f/pkg/apis/storage/types.go#L360
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 comment is still outstanding
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.
Oops, sorry for that. Instead of simply dropping the line, I decided to include historic information to avoid the mistake mentioned by Jordan (developer develops and tests with 1.23, then updating the field fails with older Kubernetes):
This field was immutable in Kubernetes <= 1.22 and now is mutable.
@@ -430,7 +430,6 @@ func ValidateCSIDriverUpdate(new, old *storage.CSIDriver) field.ErrorList { | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.FSGroupPolicy, old.Spec.FSGroupPolicy, field.NewPath("spec", "fsGroupPolicy"))...) | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.PodInfoOnMount, old.Spec.PodInfoOnMount, field.NewPath("spec", "podInfoOnMount"))...) | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.VolumeLifecycleModes, old.Spec.VolumeLifecycleModes, field.NewPath("spec", "volumeLifecycleModes"))...) | |||
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(new.Spec.StorageCapacity, old.Spec.StorageCapacity, field.NewPath("spec", "storageCapacity"))...) |
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.
The scheduler may also need updating similar to #100026 (comment). Would a pod that failed scheduling be schedulable after this object is added/removed/updated?
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.
The scheduler may also need updating similar to #100026 (comment).
That link just takes me to the PR. Are you suggesting that the scheduler needs to watch CSIDriver objects and attempt to reschedule pods when those objects change?
Would a pod that failed scheduling be schedulable after this object is added/removed/updated?
Yes. Scheduling might be blocked when the value was "true" and there is no capacity. When the value becomes "false", scheduling could proceed.
But this seems a bit unlikely. The main use case for mutating CSIDriver was to start with the "false" and later switch to "true".
My expectation was that pod scheduling is going to be retried. That seems sufficient for the less common other direction.
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.
Even though it may not be common, it would be good to handle for cases such as rollback/disablement. Similarly, the scheduler probably needs to handle CSIStorageCapacity objects as well. Anyway, I think this is orthogonal to the api change and can be investigated separately.
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.
But pod scheduling for true -> false
is handled, isn't it? It just doesn't happen immediately after the change.
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.
cc @ahg-g
My old understanding is that we would move the pod back to the scheduling queue after some period of time, but I'm not sure if that's still the case anymore and if it's all event based.
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 might make sense to fold the results of this discussion/PR into an update in https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/1472-storage-capacity-tracking and CSIDriver docs to clarify the rollout of an update to a driver that adds support for this feature. If this field becomes mutable in 1.23, I suspect people will test their driver update against latest/1.23+ versions and be surprised when their apply/update fails on 1.21 and 1.22
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.
We are working towards scheduling be purely event based. But we still have a routine that puts Pods back into the scheduling queue after 1min.
Either way, the volumebinding plugin already knows to react to CSIDriver updates https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go#L116
if this is dropping the immutability validation, it needs to start validating the new value is valid (calling validateStorageCapacity instead), right?
Shouldn't we just call ValidateCSIDriver
on the new object to be future proof against other mutability changes?
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.
PR for the KEP: kubernetes/enhancements#2854
I'm not sure whether we have specific documentation for CSIDriver
besides the auto-generated API documentation which will be updated as part of this PR.
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 seems like speeding up scheduler requeuing of unschedulable pods if a relevant reason they were unschedulable changes could be done separately from this PR (but would be worth tracking in an issue)
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 turned out that #100003 already took care of this.
/label api-review |
@@ -2063,12 +2069,6 @@ func TestCSIDriverValidationUpdate(t *testing.T) { | |||
new.Spec.FSGroupPolicy = &fileFSGroupPolicy | |||
}, | |||
}, |
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.
add a test for changing storage capacity to an invalid value and make sure it fails (it looks like nil
with CSIStorageCapacity enabled is invalid, even though we don't expect to ever encounter that because the field is defaulted to false if the feature is enabled)
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.
Added. To make it work, I had to add a call to validateCSIDriverSpec
in ValidateCSIDriverUpdate
. That wasn't necessary before when all fields were immutable but now is good to have, albeit a bit redundant because there is not much that is going to be caught by it. As you said, nil should not occur in practice.
1f8b098
to
d662cc0
Compare
The field is meant to be mutable in 1.23 (kubernetes/kubernetes#101789). While at it, document the pending issue with cluster autoscaler as a gating item for GA graduation.
d662cc0
to
8662a07
Compare
The field is meant to be mutable in 1.23 (kubernetes/kubernetes#101789). While at it, document the pending issue with cluster autoscaler as a gating item for GA graduation.
8662a07
to
ca245d9
Compare
When originally introduced, the field was made immutable to be consistent with the other fields. But in practice allowing it to be toggled makes more sense, in particular when considering the rollout of a CSI driver (let it run without using the published CSIStorageCapacity object, then flip the field, or upgrading from a driver without support to one which supports it). The only consumer of this field, the kube-scheduler, can handle mutation without problems because it always consults the informer cache to get the current value.
ca245d9
to
11ed96b
Compare
/lgtm |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, 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 |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
1 similar comment
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
What type of PR is this?
/kind feature
/kind api-change
What this PR does / why we need it:
When originally introduced, the field was made immutable to be
consistent with the other fields. But in practice allowing it to be
toggled makes more sense, in particular when considering the rollout
of a CSI driver (let it run without using the published
CSIStorageCapacity object, then flip the field, or upgrading from a
driver without support to one which supports it).
The only consumer of this field, the kube-scheduler, can handle
mutation without problems because it always consults the informer
cache to get the current value.
Which issue(s) this PR fixes:
Fixes #100089
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: