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 v1beta2 structs to object status #11234

Merged

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
This PR add v1beta2 structs to object status as defined in https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md

Part of #11105

/area api

@k8s-ci-robot k8s-ci-robot added area/api Issues or PRs related to the APIs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 27, 2024
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 27, 2024
api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/machine_types.go Outdated Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
exp/api/v1beta1/machinepool_types.go Outdated Show resolved Hide resolved
@fabriziopandini
Copy link
Member Author

@vincepri @JoelSpeed this PR add the types/conditions discussed in the proposal for phase1 + conversion tests + fixes some tests, PTAL if you have some time

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 1, 2024
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: 8916e02b4b62912d93b3c119bd318881dbd4afe4

Copy link
Member

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

Reviewed everything apart from "*/v1beta2_condition_consts.go"
Reviewing these now

api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/clusterclass_types.go Outdated Show resolved Hide resolved
api/v1beta1/machine_types.go Show resolved Hide resolved
api/v1beta1/machine_types.go Outdated Show resolved Hide resolved
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.

I didn't go through every file for API changes as it appears to be that a lot of this is duplicated across many files, but I think I've left feedback on all the kinds of API questions I'd have. Please make sure to apply the feedback across the board.

For conditions, how would we feel about conditions existing on our objects that are not known to us? Since we have SSA tags, in theory multiple owners could own the conditions list, but I'm not sure how CAPI handles this today

api/v1beta1/cluster_types.go Outdated Show resolved Hide resolved
api/v1beta1/cluster_types.go Show resolved Hide resolved
Comment on lines 502 to 503
// +optional
DesiredReplicas int32 `json:"desiredReplicas"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to care about whether this has been observed deliberately or not?

Currently, since this is not a pointer and has no omitempty, when I marshal into json, I will get desiredReplicas: 0 even if I haven't set the field. This could then cause a discrepancy with the desired replicas from the spec, and look like the controller has observed a desire for 0 replicas.

Also, should we not expect the controller to always set this field? Should it actually be required? Same probably applies to lots of the other fields as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Made all pointers,
We have to do the same for all the existing counters when we move to v1beta2 (will add to the umbrella issue)

api/v1beta1/cluster_types.go Show resolved Hide resolved
// +optional
Replicas int32 `json:"replicas"`

// upToDateReplicas is the number of up-to-date control plane machines in this cluster. A machine is considered up-to-date when Machine's UpToDate condition is true.
Copy link
Contributor

Choose a reason for hiding this comment

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

When would an UpToDate condition be true, or not? How would a user know what it means for an UpToDate condition to be true or not?

Copy link
Member Author

@fabriziopandini fabriziopandini Oct 2, 2024

Choose a reason for hiding this comment

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

We have documentation for the UpToDate condition const.
I don't think we should duplicate the same definition of every replica counter, this could easily lead to misalignment and confusion in future.

Copy link
Contributor

Choose a reason for hiding this comment

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

One thing to note is that while the documentation is up to date and correct on the conditions constants, that does not get generated into the API schema, so, is not available for users when using kubectl explain or otherwise generating docs from the schema.

I believe it would end up in swagger docs though, not sure if CAPI has generated swagger docs?

Copy link
Member Author

@fabriziopandini fabriziopandini Oct 3, 2024

Choose a reason for hiding this comment

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

We can think about swagger or about adding something to our book, but out of date comments in our API (or out of date documentation in general) is an issue we are struggling with since a long time, and I think we should really stop doing things that could make this problem worst.

Also, this is not really a problem specific of this PR only and it should be solved in a more structural way.

Also, being very pragmatic, we have time at the end of the cycle/after code freeze to improve documentation, but without go types we can't move on with the actual implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will have a think about a good way to solve this in general for the project then, otherwise PR LGTM

api/v1beta1/machine_types.go Show resolved Hide resolved
api/v1beta1/machinedeployment_types.go Show resolved Hide resolved
api/v1beta1/machinedeployment_types.go Outdated Show resolved Hide resolved
api/v1beta1/machinehealthcheck_types.go Show resolved Hide resolved
api/v1beta1/machineset_types.go Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
exp/addons/api/v1beta1/v1beta2_condition_consts.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 2, 2024
@k8s-ci-robot k8s-ci-robot requested a review from chrischdi October 2, 2024 15:17
@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Oct 2, 2024
@sbueringer
Copy link
Member

/lgtm

I think it's not necesary for ClusterSpec and MachineSpec to be comparable. In my opinion such a requirement would also severly limit our options for API design

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

LGTM label has been added.

Git tree hash: 1c59ad8a4f6857dde29c0d2a5c0a49a89d533f3f

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 2, 2024
@k8s-ci-robot
Copy link
Contributor

@fabriziopandini: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-apidiff-main fac28ef link false /test pull-cluster-api-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@sbueringer
Copy link
Member

/test pull-cluster-api-e2e-main

@sbueringer
Copy link
Member

Thx!

/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 Oct 4, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2d6527d5353d9f02d297a640b6ff01268e5cdc5f

@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 Oct 4, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9569cd6 into kubernetes-sigs:main Oct 4, 2024
17 of 19 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Oct 4, 2024
@fabriziopandini fabriziopandini deleted the add-v1beta2-structs branch October 14, 2024 08:22
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/XXL Denotes a PR that changes 1000+ 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.

6 participants