Added set and map structural validation for AllowedTopologies#66843
Added set and map structural validation for AllowedTopologies#66843k8s-github-robot merged 1 commit intokubernetes:masterfrom
Conversation
|
/sig storage |
|
/cc ddebroy |
|
@verult: GitHub didn't allow me to request PR reviews from the following users: ddebroy. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn response to this:
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. |
8963cbb to
5374495
Compare
|
/assign @liggitt |
lichuqiang
left a comment
There was a problem hiding this comment.
Thank you for help improving this!
A few minor comments, otherwise lgtm
There was a problem hiding this comment.
@msau42 , I remembered that I had this check in the initial commit,
but you'd suggest that the things of TopologySelectorTerm should be same to that of NodeSelector as much as possible, so we removed it.
Now since it has already been kind of different from NodeSelector, let's add the check here?
An empty expression won't bring users anything I guess.
5374495 to
532c86e
Compare
|
/hold tightening validation is a potentially breaking change that cannot be done without consideration of existing persisted data in etcd. This PR would invalidate persisted data, which we cannot do compatibly. see discussion in #64841 (comment) |
|
@liggitt is tightening validation not allowed even for alpha types? |
|
logic lgtm |
ah, I didn't realize it was a gated alpha field. if it is gated as alpha, that means we have no persisted data for that field in an upgradeable cluster. as long as the schema isn't changing, tightening validation seems acceptable prior to promotion of the field to beta. |
|
/hold cancel |
There was a problem hiding this comment.
think carefully about whether we'd need to extend these with other types of matchers in the future (e.g. a field matcher like this:
kubernetes/staging/src/k8s.io/api/core/v1/types.go
Lines 2400 to 2405 in a279d09
if so, we'd need to tolerate len(term.MatchLabelExpressions) == 0 in validation now to make such a future addition safe for old skewed apiservers
There was a problem hiding this comment.
What does the version skew issue look like? If a client makes a call to create a new object against an old apiserver, wouldn't it fail anyway because MatchFields doesn't exist?
There was a problem hiding this comment.
I did explicitly call it MatchLabelExpressions to leave room for other types of matchers in the future (although no concrete use cases yet)
There was a problem hiding this comment.
@liggitt can you describe more in detail the skew issue?
There was a problem hiding this comment.
@liggitt can you describe more in detail the skew issue?
What is the behavior of a TopologySelectorTerm with no MatchLabelExpressions? I'd expect it to match nothing.
Making MatchLabelExpressions required makes it very hard to make it optional in the future without breaking clients that expect a required field to stay required.
Making it optional allows adding something like MatchFieldExpressions to TopologySelectorTerm in the future without breaking clients that assume that all TopologySelectorTerm objects will contain non-zero-length MatchLabelExpressions.
There was a problem hiding this comment.
reflect.DeepEqual or semantic.DeepEqual? (reflect differentiates between nil and [], semantic does not)
There was a problem hiding this comment.
Neat, in this case reflect.DeepEqual is OK but semantic.DeepEqual is safer. Will update
fd01282 to
04c6236
Compare
04c6236 to
a805515
Compare
|
Removed empty validation on MatchLabelExpressions |
There was a problem hiding this comment.
Can you also add some positive test cases similar to these negative ones? For example, specifying the same key but across different TopologySelectorTerms
a805515 to
e5cf6f5
Compare
|
addressed comments |
|
/retest |
|
/lgtm |
|
/retest |
|
/retest Bazel test failure is due to a flake currently being addressed: #67852 |
|
api-wise, this LGTM. the changes to validation are only to fields that are currently behind alpha gates /lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, msau42, verult The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it: Adding structural validation to AllowedTopologies field in StorageClass.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #66184
Release note: