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

🌱 ClusterClass: add condition for references with outdated apiVersions #7259

Merged

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Sep 21, 2022

What this PR does / why we need it:

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 21, 2022
@sbueringer sbueringer changed the title 🌱 ClusterClass: add condition for references with outdated apiVersions [WIP] 🌱 ClusterClass: add condition for references with outdated apiVersions Sep 21, 2022
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Sep 21, 2022
@sbueringer
Copy link
Member Author

sbueringer commented Sep 21, 2022

I chose to add a separate condition for validation.

Failure state:

status:
  conditions:
  - lastTransitionTime: "2022-09-21T13:56:46Z"
    message: infrastructure.cluster.x-k8s.io/v1alpha4, Kind=DockerClusterTemplate
      should be infrastructure.cluster.x-k8s.io/v1beta1, Kind=DockerClusterTemplate,
      infrastructure.cluster.x-k8s.io/v1alpha4, Kind=DockerMachineTemplate should
      be infrastructure.cluster.x-k8s.io/v1beta1, Kind=DockerMachineTemplate, infrastructure.cluster.x-k8s.io/v1alpha4,
      Kind=DockerMachineTemplate should be infrastructure.cluster.x-k8s.io/v1beta1,
      Kind=DockerMachineTemplate
    reason: OutdatedAPIVersionsInReferences
    severity: Warning
    status: "False"
    type: ClusterClassValidationSucceeded

Success state:

status:
  conditions:
  - lastTransitionTime: "2022-09-21T13:56:46Z"
    status: "true"
    type: ClusterClassValidationSucceeded

There are a few alternatives:

  • Using a Ready condition instead => not sure what ready would mean for a ClusterClass, just because old refs are used the ClusterClass is not really "un-ready"
  • Using a more specific condition like APIVersionsUpToDate

Opinions? @fabriziopandini @vincepri @fabriziopandini @killianmuldoon

P.S. Some prior art: CRDs have some validation conditions: https://github.com/kubernetes/kubernetes/blob/e3f2d237fdb225e4835cd0985104bf01cabf6cd3/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1/types.go#L282-L301 (but they are afaik not all compliant with our conventions, e.g. Condition types MUST have a consistent polarity (i.e. "True = good"))

@sbueringer sbueringer force-pushed the pr-cc-outdated-condition branch 3 times, most recently from 8565d9a to 7157169 Compare September 21, 2022 14:36
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.

First pass

WRt to question above:

  • I'm +1 to use Using a more specific condition like APIVersionsUpToDate, or simply ReferenceUpToDate (I prefer the second one)
  • I'm -1 to use Ready condition because it is reserved for being used as a summary of all conditions; however, I will not add ready at the current stage (it is optional in the policy)

@sbueringer
Copy link
Member Author

First pass

WRt to question above:

  • I'm +1 to use Using a more specific condition like APIVersionsUpToDate, or simply ReferenceUpToDate (I prefer the second one)
  • I'm -1 to use Ready condition because it is reserved for being used as a summary of all conditions; however, I will not add ready at the current stage (it is optional in the policy)

Thx good point, adjusted accordingly

@sbueringer sbueringer changed the title [WIP] 🌱 ClusterClass: add condition for references with outdated apiVersions 🌱 ClusterClass: add condition for references with outdated apiVersions Sep 28, 2022
@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 Sep 28, 2022
@sbueringer sbueringer force-pushed the pr-cc-outdated-condition branch from 087208a to 6734e3c Compare September 28, 2022 11:21
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 28, 2022
@sbueringer sbueringer force-pushed the pr-cc-outdated-condition branch from 6734e3c to 48a6931 Compare September 28, 2022 11:23
@sbueringer
Copy link
Member Author

Should be ready for another round of review now

api/v1beta1/condition_consts.go Outdated Show resolved Hide resolved
api/v1beta1/condition_consts.go Outdated Show resolved Hide resolved
@sbueringer
Copy link
Member Author

@fabriziopandini When you have some time, would be good to get your input on condition / reason names

@sbueringer sbueringer force-pushed the pr-cc-outdated-condition branch from 48a6931 to d284deb Compare October 6, 2022 13:54
@sbueringer
Copy link
Member Author

@fabriziopandini @vincepri constants adjusted, PTAL

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

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.

/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 6, 2022
@sbueringer
Copy link
Member Author

/assign @vincepri
for final approval

api/v1beta1/condition_consts.go Outdated Show resolved Hide resolved
clusterv1.ClusterClassRefVersionsUpToDateCondition,
clusterv1.ClusterClassOutdatedRefVersionsReason,
clusterv1.ConditionSeverityWarning,
strings.Join(msg, ", "),
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using a different seperator like ; (or something else). GVK when converted to string already has , in it. The output string could be confusing.

Also, the message only uses the GVK of the ref which does not include the name. If a few DockerMachineTemplate refs are outdated that tt could be confusing if the mesage just repeats that a DockerMachineTemplate ref is outdated without pointing to the correct ref.

Copy link
Member Author

@sbueringer sbueringer Oct 7, 2022

Choose a reason for hiding this comment

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

I changed it to use a quoted string. Kept using , as separater seems slight more grammatically correct. The condition now looks like this:

  status:
    conditions:
    - lastTransitionTime: "2022-10-07T10:04:22Z"
      message: Ref "infrastructure.cluster.x-k8s.io/v1alpha4, Kind=DockerClusterTemplate
        default/quick-start-my-cluster" should be "infrastructure.cluster.x-k8s.io/v1beta1,
        Kind=DockerClusterTemplate default/quick-start-my-cluster", Ref "infrastructure.cluster.x-k8s.io/v1alpha4,
        Kind=DockerMachineTemplate default/quick-start-control-plane" should be "infrastructure.cluster.x-k8s.io/v1beta1,
        Kind=DockerMachineTemplate default/quick-start-control-plane", Ref "infrastructure.cluster.x-k8s.io/v1alpha4,
        Kind=DockerMachineTemplate default/quick-start-docker-worker-machinetemplate"
        should be "infrastructure.cluster.x-k8s.io/v1beta1, Kind=DockerMachineTemplate
        default/quick-start-docker-worker-machinetemplate"
      reason: OutdatedRefVersions
      severity: Warning
      status: "False"
      type: RefVersionsUpToDate

It's a bit verbose, but also very explicit which is probably a good thing

@sbueringer sbueringer force-pushed the pr-cc-outdated-condition branch from d284deb to c14e9fc Compare October 7, 2022 10:04
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2022
@fabriziopandini
Copy link
Member

/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 7, 2022
@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 Oct 7, 2022
@k8s-ci-robot k8s-ci-robot merged commit 9661ea3 into kubernetes-sigs:main Oct 7, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.3 milestone Oct 7, 2022
@sbueringer sbueringer deleted the pr-cc-outdated-condition branch October 7, 2022 11:45
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. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ClusterAPI upgrade workflow with ClusterClass
5 participants