-
Notifications
You must be signed in to change notification settings - Fork 36
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,16 +70,33 @@ func (r *CloudStackMachineStateCheckerReconciliationRunner) Reconcile() (ctrl.Re | |
if res, err := r.GetParent(r.ReconciliationSubject, r.CSMachine)(); r.ShouldReturn(res, err) { | ||
return res, err | ||
} | ||
|
||
if res, err := r.GetParent(r.CSMachine, r.CAPIMachine)(); r.ShouldReturn(res, err) { | ||
return res, err | ||
} | ||
|
||
if err := r.CSClient.ResolveVMInstanceDetails(r.CSMachine); err != nil && !strings.Contains(strings.ToLower(err.Error()), "no match found") { | ||
return r.ReturnWrappedError(err, "failed to resolve VM instance details") | ||
} | ||
if r.CSMachine.Status.InstanceState == "Running" { | ||
|
||
csRunning := r.CSMachine.Status.InstanceState == "Running" | ||
csTimeInState := r.CSMachine.Status.TimeSinceLastStateChange() | ||
capiRunning := r.CAPIMachine.Status.Phase == "Running" | ||
|
||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #127 |
||
|
||
if csRunning && capiRunning { | ||
r.ReconciliationSubject.Status.Ready = true | ||
} else { | ||
} else if !csRunning || capiTimeout { | ||
r.Log.Info("CloudStack instance in bad state", | ||
"name", r.CSMachine.Name, | ||
"instance-id", r.CSMachine.Spec.InstanceID, | ||
"cs-state", r.CSMachine.Status.InstanceState, | ||
"cs-time-in-state", csTimeInState.String(), | ||
"capi-phase", r.CAPIMachine.Status.Phase) | ||
|
||
if err := r.K8sClient.Delete(r.RequestCtx, r.CAPIMachine); err != nil { | ||
return r.ReturnWrappedError(err, "failed to delete CAPI machine") | ||
} | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.