@@ -726,9 +726,9 @@ func (r *ContaboMachineReconciler) bootstrapInstance(ctx context.Context, machin
726726 })
727727 if err != nil || resp .StatusCode () < 200 || resp .StatusCode () >= 300 {
728728 meta .SetStatusCondition (& contaboMachine .Status .Conditions , metav1.Condition {
729- Type : infrastructurev1beta2 .InstanceBootstrapCondition ,
730- Status : metav1 .ConditionFalse ,
731- Reason : infrastructurev1beta2 .InstanceReinstallingFailedReason ,
729+ Type : infrastructurev1beta2 .InstanceBootstrapCondition ,
730+ Status : metav1 .ConditionFalse ,
731+ Reason : infrastructurev1beta2 .InstanceReinstallingFailedReason ,
732732 Message : fmt .Sprintf ("Failed to reinstall instance, statusCode: %d" , resp .StatusCode ()),
733733 })
734734 return ctrl.Result {RequeueAfter : 15 * time .Second }, r .handleError (
@@ -1299,6 +1299,15 @@ func (r *ContaboMachineReconciler) handleError(ctx context.Context, contaboMachi
12991299func (r * ContaboMachineReconciler ) resetInstance (ctx context.Context , contaboMachine * infrastructurev1beta2.ContaboMachine , instance * infrastructurev1beta2.ContaboInstanceStatus , errorMessage * string ) error {
13001300 log := logf .FromContext (ctx )
13011301
1302+ // Remove Instance from Status
1303+ contaboMachine .Status = infrastructurev1beta2.ContaboMachineStatus {}
1304+
1305+ // Remove ProviderID
1306+ contaboMachine .Spec .ProviderID = nil
1307+
1308+ // Remove Index
1309+ contaboMachine .Spec .Index = nil
1310+
13021311 hasErrorMessage := errorMessage != nil || (instance != nil && instance .ErrorMessage != nil )
13031312
13041313 // Set error on contabo machine status
@@ -1381,19 +1390,14 @@ func (r *ContaboMachineReconciler) resetInstance(ctx context.Context, contaboMac
13811390
13821391 // Retrieve SSH key from ContaboCluster to keep access after reinstall
13831392 // Reinstall to clear any residual configuration
1384- r .ContaboClient .ReinstallInstance (ctx , instance .InstanceId , & models.ReinstallInstanceParams {}, models.ReinstallInstanceRequest {
1393+ _ , err = r .ContaboClient .ReinstallInstance (ctx , instance .InstanceId , & models.ReinstallInstanceParams {}, models.ReinstallInstanceRequest {
13851394 ImageId : DefaultUbuntuImageID ,
13861395 DefaultUser : ptr .To (models .ReinstallInstanceRequestDefaultUserAdmin ),
13871396 })
1388-
1389- // Remove Instance from Status
1390- contaboMachine .Status = infrastructurev1beta2.ContaboMachineStatus {}
1391-
1392- // Remove ProviderID
1393- contaboMachine .Spec .ProviderID = nil
1394-
1395- // Remove Index
1396- contaboMachine .Spec .Index = nil
1397+ if err != nil {
1398+ log .Error (err , "Failed to reinstall instance to reset configuration" ,
1399+ "instanceID" , instance .InstanceId )
1400+ }
13971401
13981402 return err
13991403}
0 commit comments