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

⚠️ Add MaxItems markers to API fields #11934

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Mar 5, 2025

Signed-off-by: Stefan Büringer [email protected]

What this PR does / why we need it:
This PR only enables the KAL linter for kubebuilder:validation:MaxItems. There will be other PRs for similar markers soon.

I tried to find a good trade-off between setting some reasonable upper bounds and restricting us too much, e.g. the API fields should not limit the number of MDs or Machines we can support per Cluster.

I also tried to pick similar values for similar fields and also to use only a small set of different values to make this all a bit easier.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #11834

Signed-off-by: Stefan Büringer [email protected]
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label labels Mar 5, 2025
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 5, 2025
@sbueringer sbueringer added the area/api Issues or PRs related to the APIs label Mar 5, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Mar 5, 2025
@sbueringer
Copy link
Member Author

/assign @fabriziopandini @chrischdi @JoelSpeed

PTAL and let me know if you have concerns if some of these values are too low and I'm happy to increase them.

Comment on lines +81 to +84
- path: "api/v1beta1/*"
text: "must have a maximum length, add (kubebuilder:validation:MaxLength|kubebuilder:validation:items:MaxLength) marker"
linters:
- kal
Copy link
Member Author

Choose a reason for hiding this comment

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

Will be removed via the next PRs

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

It may be interesting to try and inspect the maximum estimated size of each of these types based on the maximum request size, if you wanted to try, we do something similar in this snippet. The manual way to do it is to work out the minimum serialized size of the object and divide that into 3MiB.

@sbueringer
Copy link
Member Author

@JoelSpeed @fabriziopandini @chrischdi Thx for the reviews. PTAL :)

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

One last nit, otherwise lgtm for me

@fabriziopandini
Copy link
Member

/lgtm

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

LGTM label has been added.

Git tree hash: 8482e2aff2e20034db0dcdddeffd8778499123f5

@fabriziopandini
Copy link
Member

fabriziopandini commented Mar 10, 2025

/approve
/hold

for @JoelSpeed and @chrischdi to take another look (@sbueringer feel free to unhold if we can get additional finding fixed in a follow up)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 10, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 10, 2025
@sbueringer
Copy link
Member Author

Alrighty. Thx. I'll merge this one already. If there any further findings please let me know and I'll follow-up.

Or feel free to comment on #11949

I added markers to mostly the same fields as I did on this PR here

@sbueringer
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 10, 2025
@k8s-ci-robot k8s-ci-robot merged commit 346f861 into kubernetes-sigs:main Mar 10, 2025
19 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.10 milestone Mar 10, 2025
@sbueringer sbueringer deleted the pr-add-max-items branch March 10, 2025 15:34
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. area/api Issues or PRs related to the APIs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants