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

fix: should not set default storageclass if annotation "volume.beta.kubernetes.io/storage-class" is set #116089

Merged
merged 2 commits into from Mar 2, 2023

Conversation

cvvz
Copy link
Member

@cvvz cvvz commented Feb 27, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

No need to set default storageclass if annotation "volume.beta.kubernetes.io/storage-class" is set

Which issue(s) this PR fixes:

Fixes #116028

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixed a 1.26 regression where Kubernetes would apply a default StorageClass to a PersistentVolumeClaim,
even when the deprecated annotation `volume.beta.kubernetes.io/storage-class` was set.

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


@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/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 27, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @cvvz. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Feb 27, 2023
@k8s-ci-robot k8s-ci-robot added 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 Feb 27, 2023
@cvvz
Copy link
Member Author

cvvz commented Feb 27, 2023

cc @RomanBednar PTAL, thanks.

@sftim
Copy link
Contributor

sftim commented Feb 27, 2023

We should also document volume.beta.kubernetes.io/storage-class - see kubernetes/website#39704

@sftim
Copy link
Contributor

sftim commented Feb 27, 2023

Suggestion for the changelog entry (assuming this is actually a bug):

Fixed a bug where Kubernetes would apply a default StorageClass to a PersistentVolumeClaim,
even when the deprecated annotation `volume.beta.kubernetes.io/storage-class` was set.

@sftim
Copy link
Contributor

sftim commented Feb 27, 2023

@andyzhangx
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 28, 2023
@andyzhangx
Copy link
Member

/kind bug
/assign @jsafrane @msau42
/priority important-soon
/sig storage
/triage accepted

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Feb 28, 2023
@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed 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. labels Feb 28, 2023
@@ -937,7 +937,7 @@ func (ctrl *PersistentVolumeController) updateVolumePhaseWithEvent(volume *v1.Pe
// Ignores claims that already have a storage class.
// TODO: if resync is ever changed to a larger period, we might need to change how we set the default class on existing unbound claims
func (ctrl *PersistentVolumeController) assignDefaultStorageClass(claim *v1.PersistentVolumeClaim) (bool, error) {
if claim.Spec.StorageClassName != nil {
if storagehelpers.GetPersistentVolumeClaimClass(claim) != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a unit test for the fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, added.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 1, 2023
@liggitt liggitt added the kind/regression Categorizes issue or PR as related to a regression from a prior release. label Mar 1, 2023
@msau42
Copy link
Member

msau42 commented Mar 1, 2023

/retest

@msau42
Copy link
Member

msau42 commented Mar 1, 2023

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 1, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 19df02ce002d968d125afbbe1c367a932032ac48

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cvvz, msau42

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 Mar 1, 2023
@k8s-ci-robot k8s-ci-robot merged commit 5157158 into kubernetes:master Mar 2, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Mar 2, 2023
@andyzhangx
Copy link
Member

@cvvz could you cherry-pick to the broken releases?

@cvvz
Copy link
Member Author

cvvz commented Mar 2, 2023

@andyzhangx Sure.

k8s-ci-robot added a commit that referenced this pull request Mar 10, 2023
…-origin-release-1.26

Automated cherry pick of #116089: fix: should not set default storageclass if annotation "volume.beta.kubernetes.io/storage-class" is set
k8s-ci-robot added a commit that referenced this pull request Mar 10, 2023
…-origin-release-1.25

Automated cherry pick of #116089: fix: should not set default storageclass if annotation "volume.beta.kubernetes.io/storage-class" is set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PVs with annotations are not being dynamically provisioned on k8s 1.26.1
7 participants