Skip to content

Commit

Permalink
Fix patching OpenstackMachine's immutable spec during reconcile
Browse files Browse the repository at this point in the history
when the VM is vanished (cannot be fetched but existed at some
point)
  • Loading branch information
strudelPi committed Jan 2, 2024
1 parent e590271 commit 39b7242
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions controllers/openstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,17 @@ func (r *OpenStackMachineReconciler) getOrCreate(logger logr.Logger, cluster *cl
}

if instanceStatus == 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)
if err != nil {
conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceCreateFailedReason, clusterv1.ConditionSeverityError, err.Error())
return nil, fmt.Errorf("create OpenStack instance: %w", err)
if openStackMachine.Spec.InstanceID != nil {
logger.Info("Not reconciling machine in failed state. The previously existing OpenStack instance is no longer available")
return nil, nil
} else {
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)
if err != nil {
conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceCreateFailedReason, clusterv1.ConditionSeverityError, err.Error())
return nil, fmt.Errorf("create OpenStack instance: %w", err)
}
}
}

Expand Down

0 comments on commit 39b7242

Please sign in to comment.