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

Discard and replace new VMs if they never join the cluster #123

Merged
merged 2 commits into from
Jun 24, 2022

Conversation

mrog
Copy link
Contributor

@mrog mrog commented Jun 21, 2022

Issue #, if available:

Description of changes:
When a new VM is added to a cluster, it's possible that the VM isn't reachable on the network due to a misconfiguration or network failure. This causes CAPC to wait forever, and the cluster is never completed.

This change makes it so VMs are deleted if they don't become ready in CAPI within 5 minutes of being ready in CloudStack. The VM will then be replaced, and cluster creation can continue. Note that this change only affects newly created VMs that have not yet successfully joined a cluster.

Testing performed:
I tested it manually using EKS-Anywhere. I verified that it works for self-managed clusters, management clusters, and workload clusters. I tested with control plane nodes and worker nodes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 21, 2022
@netlify
Copy link

netlify bot commented Jun 21, 2022

Deploy Preview for kubernetes-sigs-cluster-api-cloudstack ready!

Name Link
🔨 Latest commit 187d468
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-cloudstack/deploys/62b20097a9dbd200087046d4
😎 Deploy Preview https://deploy-preview-123--kubernetes-sigs-cluster-api-cloudstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 21, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #123 (892c41a) into main (b9dc417) will decrease coverage by 0.10%.
The diff coverage is 20.68%.

@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
- Coverage   29.00%   28.90%   -0.11%     
==========================================
  Files          27       27              
  Lines        2179     2204      +25     
==========================================
+ Hits          632      637       +5     
- Misses       1473     1493      +20     
  Partials       74       74              
Impacted Files Coverage Δ
api/v1beta1/cloudstackmachine_types.go 28.57% <0.00%> (-71.43%) ⬇️
...ollers/cloudstackmachinestatechecker_controller.go 0.00% <0.00%> (ø)
api/v1beta1/zz_generated.deepcopy.go 11.42% <100.00%> (+0.16%) ⬆️
pkg/cloud/instance.go 80.34% <100.00%> (+0.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9dc417...892c41a. Read the comment docs.

Comment on lines +144 to +149
func (s *CloudStackMachineStatus) TimeSinceLastStateChange() time.Duration {
if s.InstanceStateLastUpdated.IsZero() {
return time.Duration(-1)
}
return time.Since(s.InstanceStateLastUpdated.Time)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

could we start adding some unit tests here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I just added some.

@mrog
Copy link
Contributor Author

mrog commented Jun 23, 2022

Just a reminder that this is still waiting for approval.


// capiTimeout indicates that a new VM is running, but it isn't reachable due to a network issue or a misconfiguration.
// When this happens, the machine should be deleted or else the cluster won't ever recover.
capiTimeout := csRunning && !capiRunning && csTimeInState > 5*time.Minute
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be configurable instead of hardcoded? Maybe default to 5 minutes, unless some env var is set or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd love to have a good mechanism for making it configurable. I wish we could put something in the EKS-A cluster definition file, but nothing there passes through nicely. Is there a good way to set environment variables on the VMs in bulk?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's create a GitHub issue and move forward without this configuration for now, since it's not essential.

Copy link
Contributor

Choose a reason for hiding this comment

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

Created #127

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maxdrib, mrog

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 Jun 24, 2022
@jweite-amazon
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 24, 2022
@k8s-ci-robot k8s-ci-robot merged commit 773258f into kubernetes-sigs:main Jun 24, 2022
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants