Content-Length: 461688 | pFad | http://github.com/kubernetes/kubernetes/pull/132106

CD Allow PVC VACName to go from non-nil to nil by AndrewSirenko · Pull Request #132106 · kubernetes/kubernetes · GitHub
Skip to content

Allow PVC VACName to go from non-nil to nil #132106

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndrewSirenko
Copy link
Contributor

@AndrewSirenko AndrewSirenko commented Jun 4, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

PR kubernetes-csi/external-resizer#487 will allow users using ModifyVolume feature via VolumeAttributesClass to rollback from an infeasible pvc.spec.VacName to no VAC.

However, kube-api-server includes validations to prevent going from non-nil pvc/pv VACName to nil VACName.

This PR loosens those PVC/PV Update validations. External-resizer sidecar will ensure user can only rollback infeasible modifications to nil.

For additional context see slack thread: https://kubernetes.slack.com/archives/C8EJ01Z46/p1748628161127689

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

/cc @gnufied
/cc @sunnylovestiramisu
/cc @msau42
/cc @xing-yang

Tested on an AWS kOps cluster alongside aws-ebs-csi-driver. See K/K VAC Validation changes + Sunny's resizer PR.

Does this PR introduce a user-facing change?

Allow pvc.spec.VolumeAttributesClassName to go from non-nil to nil

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


@k8s-ci-robot k8s-ci-robot requested a review from gnufied June 4, 2025 20:56
@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot requested a review from msau42 June 4, 2025 20:56
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 4, 2025
@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 4, 2025
@k8s-ci-robot k8s-ci-robot requested a review from xing-yang June 4, 2025 20:56
@k8s-ci-robot k8s-ci-robot added 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-kind Indicates a PR lacks a `kind/foo` label and requires one. 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 Jun 4, 2025
@k8s-ci-robot
Copy link
Contributor

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 4, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Apps Jun 4, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AndrewSirenko
Once this PR has been reviewed and has the lgtm label, please assign msau42 for approval. For more information see the Code Review Process.

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

@@ -2155,11 +2155,6 @@ func ValidatePersistentVolumeUpdate(newPv, oldPv *core.PersistentVolume, opts Pe
if !utilfeature.DefaultFeatureGate.Enabled(features.VolumeAttributesClass) {
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "volumeAttributesClassName"), "update is forbidden when the VolumeAttributesClass feature gate is disabled"))
}
if opts.EnableVolumeAttributesClass {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Presume we want to remove the validation for PV as well so that we avoid situation where PVC can be nil but PV somehow stuck non-nil.

@@ -2427,7 +2422,7 @@ func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *core.PersistentVolumeCl
newPvcClone.Spec.Resources.Requests["storage"] = oldPvc.Spec.Resources.Requests["storage"] // +k8s:verify-mutation:reason=clone
}
// lets make sure volume attributes class name is same.
if newPvc.Status.Phase == core.ClaimBound && newPvcClone.Spec.VolumeAttributesClassName != nil {
if newPvc.Status.Phase == core.ClaimBound {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was required to prevent this err:

❯ k patch pvc ebs-claim --patch '{"spec": {"volumeAttributesClassName": null}}'
The PersistentVolumeClaim "ebs-claim" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests and volumeAttributesClassName for bound claims
  core.PersistentVolumeClaimSpec{
  	... // 6 identical fields
  	DataSource:                nil,
  	DataSourceRef:             nil,
- 	VolumeAttributesClassName: &"io3-class",
+ 	VolumeAttributesClassName: nil,
  }

enableVolumeAttributesClass: true,
isExpectedFailure: true,
},
"invalid-update-volume-attributes-class-to-nil": {
oldClaim: validClaimVolumeAttributesClass1,
newClaim: validClaimNilVolumeAttributesClass,
enableVolumeAttributesClass: true,
isExpectedFailure: true,
isExpectedFailure: false,
},
"invalid-update-volume-attributes-class-to-empty": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like the same test case as line 3035 "invalid-update-volume-attributes-class"?

Copy link
Contributor Author

@AndrewSirenko AndrewSirenko Jun 5, 2025

Choose a reason for hiding this comment

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

Yes there existed duplicate tests with different names.

I presume the intent of "invalid-update-volume-attributes-class" is to catch some invalid update, while the existence of "invalid-update-volume-attributes-class-to-empty" AND "invalid-update-volume-attributes-class-to-nil" was to test these specific cases. But happy to delete one of the duplicate tests.

Either way I realize I need to change the name of this test to valid-update-vac-to-nil now that it is valid. Thanks!

@@ -3034,15 +3034,15 @@ func TestValidatePersistentVolumeClaimUpdate(t *testing.T) {
},
"invalid-update-volume-attributes-class": {
oldClaim: validClaimVolumeAttributesClass1,
newClaim: validClaimNilVolumeAttributesClass,
newClaim: validClaimEmptyVolumeAttributesClass,
enableVolumeAttributesClass: true,
isExpectedFailure: true,
},
"invalid-update-volume-attributes-class-to-nil": {
Copy link
Contributor

Choose a reason for hiding this comment

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

invalid -> valid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will refactor this helper's name next revision.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a test case for string to empty-string and expect error?

@AndrewSirenko AndrewSirenko marked this pull request as ready for review June 5, 2025 15:22
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 5, 2025
@gnufied
Copy link
Member

gnufied commented Jun 5, 2025

Can you make this a real PR so as tests are running? I am not sure if we run tests on draft PRs.

@AndrewSirenko
Copy link
Contributor Author

Can you make this a real PR so as tests are running?

@gnufied Jinx!

Looks like tests all passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. 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/apps Categorizes an issue or PR as relevant to SIG Apps. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/kubernetes/kubernetes/pull/132106

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy