Skip to content

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Jul 1, 2025

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 #10852

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 1, 2025
@sbueringer sbueringer added the area/api Issues or PRs related to the APIs label Jul 1, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Jul 1, 2025
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch from e0ec217 to dbe8095 Compare July 1, 2025 16:35
Copy link
Member Author

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

/hold
for discussion

@fabriziopandini @JoelSpeed PTAL

@@ -1184,8 +1185,8 @@ type Cluster struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec is the desired state of Cluster.
// +optional
Spec ClusterSpec `json:"spec,omitempty"`
// +required
Copy link
Member Author

Choose a reason for hiding this comment

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

required because either Cluster.spec.topology or Cluster.spec.controlPlaneRef / infrastructureRef should be set. An empty Cluster does not work

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that validated in a webhook currently? That should be easy to validate in CEL and would make it easier to appreciate that this rule exists

Copy link
Member Author

Choose a reason for hiding this comment

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

No, there is no validation today. Neither in OpenAPI validation nor in the webhook.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could probably build some ratcheting validation to enforce this in the future, something for the backlog maybe

Copy link
Member Author

@sbueringer sbueringer Jul 2, 2025

Choose a reason for hiding this comment

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

Yeah, will track as a follow-up to improve this (we'll also write up the variations of infraRef/cpRef/topology being set/unset that make sense)

@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 Jul 1, 2025
@sbueringer sbueringer changed the title [WIP] ⚠️ Align Spec fields to optionalfields API conventions ⚠️ Align Spec fields to optionalfields API conventions Jul 1, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 1, 2025
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch from dbe8095 to 14067e6 Compare July 1, 2025 16:42
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@kubernetes-sigs kubernetes-sigs deleted a comment from k8s-ci-robot Jul 1, 2025
// +optional
Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec,omitempty,omitzero"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change from required?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it actually is optional and I aligned this here to the same field in KubeadmConfigTemplate which is also optional

Copy link
Member Author

Choose a reason for hiding this comment

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

Verified it is actually optional

@@ -1184,8 +1185,8 @@ type Cluster struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec is the desired state of Cluster.
// +optional
Spec ClusterSpec `json:"spec,omitempty"`
// +required
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that validated in a webhook currently? That should be easy to validate in CEL and would make it easier to appreciate that this rule exists

@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch 2 times, most recently from 9e87ba6 to b51663d Compare July 2, 2025 19:15
@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch from b51663d to c099e66 Compare July 2, 2025 19:18
@sbueringer
Copy link
Member Author

Rebased on top of main

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch from c099e66 to d35e8dc Compare July 3, 2025 07:24
@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 Jul 3, 2025
@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch 2 times, most recently from 341c983 to 717a702 Compare July 3, 2025 08:05
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer sbueringer force-pushed the pr-optionalfields-spec branch from 717a702 to 8573573 Compare July 3, 2025 17:14
@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 3, 2025
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@fabriziopandini
Copy link
Member

Great Job!
Tested all the resources one by one by creating objects without spec and then object with the minimal supported spec, everything works nicely

/lgtm

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

LGTM label has been added.

Git tree hash: d09fe1cfe1fc6574f218cdf476f0b8852b8361a7

@sbueringer
Copy link
Member Author

sbueringer commented Jul 4, 2025

/override pull-cluster-api-e2e-main

Unrelated flake. I have a PR stacked on top of this and the test there is green (but also a bit flaky sometimes)

EDIT: This test (https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_cluster-api/12431/pull-cluster-api-e2e-main/1940969900210130944) became flaky very recently across all our branches (including release-1.10 / release-1.9 / release-1.8). So entirely unrelated to this PR.

@k8s-ci-robot
Copy link
Contributor

@sbueringer: Overrode contexts on behalf of sbueringer: pull-cluster-api-e2e-main

In response to this:

/override pull-cluster-api-e2e-main

Unrelated flake. I have a PR stacked on top of this and the test there is green (but also a bit flaky sometimes)

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.

@sbueringer
Copy link
Member Author

Going to merge this one so we can already review #12299 more easily (Fabrizio is on PTO next week)

@JoelSpeed If you have further findings, just let me know and I'll follow-up quickly

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Jul 4, 2025
@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 Jul 4, 2025
@k8s-ci-robot k8s-ci-robot merged commit 17b5d2a into kubernetes-sigs:main Jul 4, 2025
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.11 milestone Jul 4, 2025
@sbueringer sbueringer deleted the pr-optionalfields-spec branch July 4, 2025 06:40
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/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants