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

[release-0.9] 🐛 Fix patching OpenstackMachine's immutable spec during reconcile #1819

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion controllers/openstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
}

instanceStatus, err := r.getOrCreate(scope.Logger(), cluster, openStackCluster, machine, openStackMachine, computeService, userData)
if err != nil {
if err != nil || instanceStatus == nil {
// Conditions set in getOrCreate
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -439,6 +439,12 @@ func (r *OpenStackMachineReconciler) getOrCreate(logger logr.Logger, cluster *cl
}

if instanceStatus == nil {
if openStackMachine.Spec.InstanceID != nil {
logger.Info("Not reconciling machine in failed state. The previously existing OpenStack instance is no longer available")
conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceNotFoundReason, clusterv1.ConditionSeverityError, "virtual machine no longer exists")
openStackMachine.SetFailure(capierrors.UpdateMachineError, errors.New("virtual machine no longer exists"))
return nil, nil
}
instanceSpec := machineToInstanceSpec(openStackCluster, machine, openStackMachine, userData)
logger.Info("Machine does not exist, creating Machine", "name", openStackMachine.Name)
instanceStatus, err = computeService.CreateInstance(openStackMachine, openStackCluster, instanceSpec, cluster.Name)
Expand Down