@@ -193,8 +193,9 @@ func (r *CloudStackMachineReconciliationRunner) GetOrCreateVMInstance() (retRes
193193
194194 if err == nil && ! controllerutil .ContainsFinalizer (r .ReconciliationSubject , infrav1 .MachineFinalizer ) { // Fetched or Created?
195195 r .Log .Info ("CloudStack instance Created" , "instanceStatus" , r .ReconciliationSubject .Status )
196- controllerutil .AddFinalizer (r .ReconciliationSubject , infrav1 .MachineFinalizer )
197196 }
197+ // Always add the finalizer regardless. It can't be added twice anyway.
198+ controllerutil .AddFinalizer (r .ReconciliationSubject , infrav1 .MachineFinalizer )
198199 return ctrl.Result {}, err
199200}
200201
@@ -204,7 +205,7 @@ func (r *CloudStackMachineReconciliationRunner) RequeueIfInstanceNotRunning() (r
204205 r .Log .Info ("Machine instance is Running..." )
205206 r .ReconciliationSubject .Status .Ready = true
206207 } else if r .ReconciliationSubject .Status .InstanceState == "Error" {
207- r .Log .Info ("CloudStackMachine VM in error state. Deleting associated Machine." , "csMachine" , r .ReconciliationSubject )
208+ r .Log .Info ("CloudStackMachine VM in error state. Deleting associated Machine." , "csMachine" , r .ReconciliationSubject . GetName () )
208209 if err := r .K8sClient .Delete (r .RequestCtx , r .CAPIMachine ); err != nil {
209210 return ctrl.Result {}, err
210211 }
@@ -259,6 +260,7 @@ func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.R
259260 }
260261 return ctrl.Result {}, err
261262 }
263+ r .Log .Info ("VM Deleted." )
262264 controllerutil .RemoveFinalizer (r .ReconciliationSubject , infrav1 .MachineFinalizer )
263265 return ctrl.Result {}, nil
264266}
0 commit comments