Skip to content

Conversation

v47
Copy link
Contributor

@v47 v47 commented Sep 3, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  • Enables Kube API linter’s requiredfields check to ensure required API fields aren’t omitted or pointer types.
  • Removes omitempty tags from required OIDC identity provider fields and MachinePool block device DeviceName fields to align with new linter rules and guarantee proper serialization.

Which issue(s) this PR fixes :
Fixes #5492

Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:

Enabled requiredfields Kube API linter check and removed `omitempty` tags from required EKS and experimental MachinePool API fields.

@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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 3, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign dlipovetsky for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-priority needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 3, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @v47. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@fiunchinho
Copy link
Contributor

/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 Sep 3, 2025
@JoelSpeed
Copy link

Please update KAL to the latest version. After discussion with the Kube API reviewers, and updates to the Kube API conventions, the required fields rule has been rewritten and will now recommend omitempty on fields, so this PR is going in the opposite direction to the current best advice

@damdo
Copy link
Member

damdo commented Sep 3, 2025

/hold

@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 Sep 3, 2025
@richardcase
Copy link
Member

Also the PR needs a retitle.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 4, 2025
…ditions checks in .golangci-kal.yml (comment out conditions config). The older version was not picking them.
@v47 v47 force-pushed the enable-commentstart-linter branch from 2f48458 to 43a07db Compare September 4, 2025 01:22
@v47 v47 changed the title 🌱 enable commentstart linter 🌱 enable requiredfields linter Sep 4, 2025
Copy link

@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.

In a lot of cases, changing the serialization can be breaking, though clients do need to update to the new library version for this to take effect.

Where we already have a non-zero min length, adding omitempty/omitzero should be safe, since no one should have persisted an empty value anyway

Where there aren't min lengths already, this could be problematic. Have you checked what the behaviour is when a zero value is persisted and you upgrade into this schema/client?

Existing values should be fine because of ratcheting validation, but, if the client now starts omitting the value, it will remove the value on write and this will lead to a required validation coming up, which would then be breaking

@@ -223,6 +223,7 @@ type OIDCIdentityProviderConfig struct {
// This is also known as audience. The ID for the client application that makes
// authentication requests to the OpenID identity provider.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1

Choose a reason for hiding this comment

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

Have you verified that this ratchets?

@@ -250,6 +252,8 @@ type OIDCIdentityProviderConfig struct {
// and must be publicly accessible over the internet.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern=`^https://.+`

Choose a reason for hiding this comment

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

Might be better to use a CEL validation if possible, isURL likely more comprehensive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you have something like this in mind?

// +kubebuilder:validation:XValidation:rule="isURL(self) && url(self).getScheme() == 'https'"

Choose a reason for hiding this comment

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

Exactly, and then you can add ,message="..." with a custom error message too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

[KAL] Enable the requiredfields linter
6 participants