Skip to content

Conversation

@aaron-prindle
Copy link
Contributor

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 8, 2025
@k8s-ci-robot k8s-ci-robot requested review from apelisse and deads2k May 8, 2025 13:28
@k8s-ci-robot k8s-ci-robot added kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 8, 2025
@aaron-prindle aaron-prindle force-pushed the kep-5073-update-cross-field branch 2 times, most recently from 63eae72 to a65ce7c Compare May 8, 2025 14:37
@aaron-prindle
Copy link
Contributor Author

/assign @deads2k @jpbetz @thockin
/cc @yongruilin

Comment on lines 1052 to 1057
#### Cross-Field Validation and Ratcheting
For cross-field validations, the validation logic is evaluated at the common ancestor of the fields involved. This approach is necessary for supporting ratcheting. While validation tags (eg: +k8s:maximum=siblingField, +k8s:unionMember , etc.) may be placed on an individual field for clarity, the tag and its associated validation logic will be "hoisted" to the parent struct during code generation. This "hoisting" means the validation is treated as if it were defined on the common ancestor. By anchoring the cross-field alidation logic at the common ancestor, regardless of tag placement, the ratcheting design can more reliably determine how to perform equality checks across the relevant type nodes and decide if re-validation is necessary.

As noted in the Ratcheting section there is an additional challenge that arises if a cross-field validation rule (e.g. X < Y) is defined on a common ancestor struct/field, and an unrelated field (e.g. Z) within that same ancestor is modified. This change to Z makes the common ancestor “changed” overall, triggering re-validation of the X < Y rule. If this rule was recently evolved, it might now fail even if X and Y themselves are not modified by the user’s update. This could violate the principle “Unchanged fields do not cause update rejections”. In practice this means that the validation rules (or validation-gen generally) might have to be more explicit where each validation rule explains “I only care about these fields for ratcheting”.

For the initial implementation, this behavior will be documented, and cross-field validation rules must handle ratcheting themselves. This means that in the initial implementation of the cross-field dedicated tags referenced in the document (+k8s:unionMember, etc.), they will handle ratcheting of the fields they operate on directly. See the Ratcheting section for more information on this issue as well as longer term plans on addressing this challenge.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it is more nature that first paragraph is in cross-field section and the 2nd & 3rd paragraphs are in ratcheting section? Maybe you don't need to put a sub-title for that 1st paragraph and then refer to the ratcheting section of how to handle this challenge case?

Copy link
Contributor Author

@aaron-prindle aaron-prindle May 8, 2025

Choose a reason for hiding this comment

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

+1, I've combined paragraphs 2 & 3 into a single paragraph and de-duped the majority of text from the Ratcheting and Cross-Field Validation section in #5292. This paragraph now explains:

  • cross-field tags "hoist" all cross-field tags to the parent struct
  • cross-field tags implement ratcheting for the fields they operate on

Copy link
Contributor

@jpbetz jpbetz left a comment

Choose a reason for hiding this comment

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

nit only, looks good!

@aaron-prindle aaron-prindle force-pushed the kep-5073-update-cross-field branch from e67cef8 to 8d62579 Compare May 8, 2025 19:30
Copy link
Contributor

@deads2k deads2k left a comment

Choose a reason for hiding this comment

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

I wasn't expecting to see CEL in the table. I agree with the rest, though particulars around usage of the tags will need to be worked out. Do you want to do it here, on a followup KEP update, on the implementation PR, or somewhere else?

// +k8s:subfield({"type":"Denied", "status": "true"})=+k8s:unionMember

// +k8s:subfield({"type":"Failed"})=+k8s:optional
// +k8s:subfield({"type":"Failed"})=+k8s:immutable
Copy link
Contributor

Choose a reason for hiding this comment

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

The impl PR will go into the "immutable after create" versus "immutable once set"?

Copy link
Contributor Author

@aaron-prindle aaron-prindle May 15, 2025

Choose a reason for hiding this comment

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

Yes, the related impl KEP Update will go into the "immutable after create" versus "immutable once set".

@deads2k
Copy link
Contributor

deads2k commented May 15, 2025

oh, and a note that breaking on sentences makes it easier to comment on the right lines.

@aaron-prindle aaron-prindle force-pushed the kep-5073-update-cross-field branch from f63f0af to 40bfe3a Compare May 15, 2025 21:09
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 15, 2025
@aaron-prindle
Copy link
Contributor Author

oh, and a note that breaking on sentences makes it easier to comment on the right lines.

Noted, I've updated the KEP Update changes here to break on sentences now.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 6, 2025
@aaron-prindle aaron-prindle force-pushed the kep-5073-update-cross-field branch from 40bfe3a to 22e5865 Compare June 10, 2025 23:24
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 10, 2025
@aaron-prindle aaron-prindle force-pushed the kep-5073-update-cross-field branch 2 times, most recently from f4378f8 to 2342156 Compare June 10, 2025 23:39
@aaron-prindle aaron-prindle force-pushed the kep-5073-update-cross-field branch from 2342156 to ff2a6da Compare June 10, 2025 23:44
@deads2k
Copy link
Contributor

deads2k commented Jun 11, 2025

I think this still works well with the other bits we've landed.

/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 Jun 11, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aaron-prindle, deads2k

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 Jun 11, 2025
@k8s-ci-robot k8s-ci-robot merged commit 020fe69 into kubernetes:master Jun 11, 2025
2 of 4 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.34 milestone Jun 11, 2025
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/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants