Skip to content
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

Merged
merged 2 commits into from Aug 12, 2021

Conversation

pohly
Copy link
Contributor

@pohly pohly commented May 7, 2021

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?

CSIDriver.Spec.StorageCapacity can now be modified.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1472-storage-capacity-tracking

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 7, 2021
@k8s-ci-robot
Copy link
Contributor

@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 triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 7, 2021
@fejta-bot
Copy link

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.

@pohly
Copy link
Contributor Author

pohly commented May 26, 2021

/assign @msau42

Copy link
Member

@msau42 msau42 left a 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"))...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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

Copy link
Contributor Author

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"))...)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)

#104250

Copy link
Contributor Author

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.

@msau42
Copy link
Member

msau42 commented Jun 2, 2021

/label api-review

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Jun 2, 2021
@liggitt liggitt added this to Backlog in API Reviews Aug 5, 2021
@liggitt liggitt self-assigned this Aug 5, 2021
@@ -2063,12 +2069,6 @@ func TestCSIDriverValidationUpdate(t *testing.T) {
new.Spec.FSGroupPolicy = &fileFSGroupPolicy
},
},
Copy link
Member

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)

Copy link
Contributor Author

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.

@liggitt liggitt moved this from Backlog to Changes requested in API Reviews Aug 5, 2021
pohly added a commit to pohly/enhancements that referenced this pull request Aug 9, 2021
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.
pohly added a commit to pohly/enhancements that referenced this pull request Aug 11, 2021
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.
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2021
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.
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2021
@alculquicondor
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 11, 2021
@liggitt
Copy link
Member

liggitt commented Aug 11, 2021

/lgtm
/approve

@liggitt liggitt moved this from Changes requested to API review completed, 1.23 in API Reviews Aug 11, 2021
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 11, 2021
@k8s-triage-robot
Copy link

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:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

1 similar comment
@k8s-triage-robot
Copy link

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:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@k8s-ci-robot k8s-ci-robot merged commit 7ee94f2 into kubernetes:master Aug 12, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: API review completed, 1.23
Development

Successfully merging this pull request may close these issues.

CSIDriver.StorageCapacity: allow mutating the field
7 participants