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

🐛 Fix the description of ControlPlaneInitializedCondition is misleading #6999

Conversation

13164815445
Copy link

@13164815445 13164815445 commented Aug 2, 2022

…ncileControlPlane

What this PR does / why we need it:

cluster ControlPlaneInitializedCondition reports if the cluster's control plane has been initialized such that the cluster's apiserver is reachable and at least one control plane Machine has a node reference,
but in the scenario where ControlPlaneRef is not nil, we cannot determine whether there is a control plane machine, and we can only judge by the ControlPlaneInitializedCondition of the control plane, so I think it is necessary to modify the description of cluster ControlPlaneInitialized

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

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 2, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: 13164815445 / name: luyu (42d1bb7)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 2, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @13164815445!

It looks like this is your first PR to kubernetes-sigs/cluster-api 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 2, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @13164815445. 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/test-infra repository.

@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 neolit123 for approval by writing /assign @neolit123 in a comment. For more information see:The Kubernetes 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 the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 2, 2022
@13164815445
Copy link
Author

/easycla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 2, 2022
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/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 Aug 2, 2022
@killianmuldoon
Copy link
Contributor

/retest

@killianmuldoon
Copy link
Contributor

I'm re-running the tests in case there's a flake, but I think the implementation here doesn't match the path laid out in #4936. @13164815445 there's a guide to running the end to end tests locally in the Cluster API book if you want to drill down on what the root cause of the test failure is.

@chrischdi
Copy link
Member

I think we cannot just remove setting the condition because, as Vince mentioned, the two codepaths are mutual exclusive.

for _, m := range machines {
if util.IsControlPlaneMachine(m) && m.Status.NodeRef != nil {
conditions.MarkTrue(cluster, clusterv1.ControlPlaneInitializedCondition)
return ctrl.Result{}, nil
}
}

Will get executed when not using a ControlPlane provider

// Update cluster.Status.ControlPlaneInitialized if it hasn't already been set
// Determine if the control plane provider is initialized.
if !conditions.IsTrue(cluster, clusterv1.ControlPlaneInitializedCondition) {
initialized, err := external.IsInitialized(controlPlaneConfig)
if err != nil {
return ctrl.Result{}, err
}
if initialized {
conditions.MarkTrue(cluster, clusterv1.ControlPlaneInitializedCondition)
} else {

Otherwise.

So we still need both codepaths if I got it right.

Would be great to replicate the issue, check which of both codepaths is executed in the described case of the issue and check what could be done to only mark it to true if is okay to do so.

@13164815445
Copy link
Author

13164815445 commented Aug 4, 2022

I'm re-running the tests in case there's a flake, but I think the implementation here doesn't match the path laid out in #4936. @13164815445 there's a guide to running the end to end tests locally in the Cluster API book if you want to drill down on what the root cause of the test failure is.

This is my problem, I didn't take into account the difference between setting and not setting controlplaneref

I want to add machine judgment in the reconcileControlPlane method, but I am not sure if there is a control plane machine in the scene if ControlPlaneRef is not nil

@13164815445
Copy link
Author

I think we cannot just remove setting the condition because, as Vince mentioned, the two codepaths are mutual exclusive.

for _, m := range machines {
if util.IsControlPlaneMachine(m) && m.Status.NodeRef != nil {
conditions.MarkTrue(cluster, clusterv1.ControlPlaneInitializedCondition)
return ctrl.Result{}, nil
}
}

Will get executed when not using a ControlPlane provider

// Update cluster.Status.ControlPlaneInitialized if it hasn't already been set
// Determine if the control plane provider is initialized.
if !conditions.IsTrue(cluster, clusterv1.ControlPlaneInitializedCondition) {
initialized, err := external.IsInitialized(controlPlaneConfig)
if err != nil {
return ctrl.Result{}, err
}
if initialized {
conditions.MarkTrue(cluster, clusterv1.ControlPlaneInitializedCondition)
} else {

Otherwise.

So we still need both codepaths if I got it right.

Would be great to replicate the issue, check which of both codepaths is executed in the described case of the issue and check what could be done to only mark it to true if is okay to do so.

I think you are right, we still need both codepaths

If ControlPlaneInitializedCondition only means that the control plane is available, then it is correct now, I am wondering if I just need to change the comment

If a machine must be guaranteed to be available, then we must ensure that controlplaneref is not nil, and the control plane machine must exist

@13164815445 13164815445 force-pushed the ControlPlaneInitialized-update branch from 42d1bb7 to 7e8d978 Compare August 9, 2022 05:42
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 9, 2022
@13164815445 13164815445 changed the title 🐛 Fix remove cluster condition ControlPlaneInitialized update in reco… 🐛 Fix the description of ControlPlaneInitializedCondition is misleading Aug 9, 2022
@@ -59,7 +59,7 @@ const (

const (
// ControlPlaneInitializedCondition reports if the cluster's control plane has been initialized such that the
// cluster's apiserver is reachable and at least one control plane Machine has a node reference. Once this
// cluster's apiserver is reachable or at least one control plane Machine has a node reference. Once this
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't change v1alpha4

Comment on lines +62 to 64
// cluster's apiserver is reachable or at least one control plane Machine has a node reference. Once this
// condition is marked true, its value is never changed. See the ControlPlaneReady condition for an indication of
// the current readiness of the cluster's control plane.
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed we should be able to leave the condition as is and update the comment instead. @13164815445 WDYT about:

Suggested change
// cluster's apiserver is reachable or at least one control plane Machine has a node reference. Once this
// condition is marked true, its value is never changed. See the ControlPlaneReady condition for an indication of
// the current readiness of the cluster's control plane.
// cluster's apiserver is reachable. If no Control Plane provider is in use this condition reports that at least one control plane Machine has a node reference. Once this
// condition is marked true, its value is never changed. See the ControlPlaneReady condition for an indication of
// the current readiness of the cluster's control plane.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 20, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 20, 2022
@k8s-ci-robot k8s-ci-robot added the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Dec 20, 2022
@killianmuldoon
Copy link
Contributor

@13164815445 do you think you'll have time to come back to this PR? If not we can close and let someone else pick it up.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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/test-infra repository.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ControlPlaneInitialized condition is set before a control-plane Node is ready
5 participants