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
pkg/admission/storageclass: pick one storageclass conditionally if >1 present #110559
pkg/admission/storageclass: pick one storageclass conditionally if >1 present #110559
Conversation
Hi @danishprakash. 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 Once the patch is verified, the new status will be reflected by the 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. |
rand.Seed(time.Now().UnixNano()) | ||
return defaultClasses[rand.Intn(len(defaultClasses))], 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.
@thockin I've used rand here for starters, but is there a heuristic we have in mind that we can employ here. I'm open to suggestions, thanks.
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.
Tim should we not have to be consistent in a multimaster deployment?
If we have 2 or more apiservers, I think that all of them should pick the same default
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 think that sorting it alphabetically and returning the first one will make 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.
Why not sort by CreationTimestamp
and choose the newest one (on the assumption that this situation USUALLY means someone is adding a new one and removing an old one)?
e62a753
to
46d883f
Compare
@@ -170,7 +170,7 @@ func TestAdmission(t *testing.T) { | |||
"two defaults, error with PVC with class=nil", | |||
[]*storagev1.StorageClass{defaultClass1, defaultClass2, classWithFalseDefault, classWithNoDefault, classWithEmptyDefault}, | |||
claimWithNoClass, | |||
true, | |||
false, |
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 a testcase for multiple defaults?
The IngressClass PR was approved |
I'll update this today, thanks for the heads up. |
/approve @danishprakash please add a release note in the first comment of this PR, this is user-facing change. |
/lgtm |
if len(defaultClasses) > 1 { | ||
klog.V(4).Infof("GetDefaultClass %d defaults found", len(defaultClasses)) | ||
return nil, errors.NewInternalError(fmt.Errorf("%d default StorageClasses were found", len(defaultClasses))) | ||
klog.V(4).Infof("%d default StorageClasses were found, choosing the newest: %s", len(defaultClasses), defaultClasses[0].Name) |
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.
Also put in release note (and maybe the PR description) that the newest is preferred?
Should we document this in the API?
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.
Strictly speaking this is optional and not part of the API :)
plugin/pkg/admission/storage/storageclass/setdefault/admission.go
Outdated
Show resolved
Hide resolved
ping, I 'd love to approve this |
Signed-off-by: danishprakash <grafitykoncept@gmail.com>
Signed-off-by: danishprakash <grafitykoncept@gmail.com>
3c961e4
to
f10f4d3
Compare
I updated the relnote a bit. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danishprakash, jsafrane, thockin 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 this PR does / why we need it:
If there are two StorageClasses, currently we don't pick either of them as the default as part of admission control. This change picks one StorageClass at random.
Which issue(s) this PR fixes:
Fixes #110514
Signed-off-by: danishprakash grafitykoncept@gmail.com
Does this PR introduce a user-facing change?