@@ -143,7 +143,8 @@ func (r *PacketMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reques
143
143
144
144
// Handle deleted machines
145
145
if ! packetmachine .ObjectMeta .DeletionTimestamp .IsZero () {
146
- return r .reconcileDelete (ctx , machineScope )
146
+ err = r .reconcileDelete (ctx , machineScope )
147
+ return ctrl.Result {}, err
147
148
}
148
149
149
150
return r .reconcile (ctx , machineScope )
@@ -435,7 +436,7 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
435
436
return result , nil
436
437
}
437
438
438
- func (r * PacketMachineReconciler ) reconcileDelete (ctx context.Context , machineScope * scope.MachineScope ) (ctrl. Result , error ) {
439
+ func (r * PacketMachineReconciler ) reconcileDelete (ctx context.Context , machineScope * scope.MachineScope ) error {
439
440
log := ctrl .LoggerFrom (ctx , "machine" , machineScope .Machine .Name , "cluster" , machineScope .Cluster .Name )
440
441
log .Info ("Reconciling Delete PacketMachine" )
441
442
@@ -453,13 +454,13 @@ func (r *PacketMachineReconciler) reconcileDelete(ctx context.Context, machineSc
453
454
packet .DefaultCreateTags (machineScope .Namespace (), machineScope .Machine .Name , machineScope .Cluster .Name ),
454
455
)
455
456
if err != nil {
456
- return ctrl. Result {}, err
457
+ return err
457
458
}
458
459
459
460
if dev == nil {
460
461
log .Info ("Server not found by tags, nothing left to do" )
461
462
controllerutil .RemoveFinalizer (packetmachine , infrav1 .MachineFinalizer )
462
- return ctrl. Result {}, nil
463
+ return nil
463
464
}
464
465
465
466
device = dev
@@ -474,18 +475,18 @@ func (r *PacketMachineReconciler) reconcileDelete(ctx context.Context, machineSc
474
475
// Probably somebody manually deleted the server from the UI or via API.
475
476
log .Info ("Server not found by id, nothing left to do" )
476
477
controllerutil .RemoveFinalizer (packetmachine , infrav1 .MachineFinalizer )
477
- return ctrl. Result {}, nil
478
+ return nil
478
479
}
479
480
480
481
if resp .StatusCode == http .StatusForbidden {
481
482
// When a server fails to provision it will return a 403
482
483
log .Info ("Server appears to have failed provisioning, nothing left to do" )
483
484
controllerutil .RemoveFinalizer (packetmachine , infrav1 .MachineFinalizer )
484
- return ctrl. Result {}, nil
485
+ return nil
485
486
}
486
487
}
487
488
488
- return ctrl. Result {}, fmt .Errorf ("error retrieving machine status %s: %w" , packetmachine .Name , err )
489
+ return fmt .Errorf ("error retrieving machine status %s: %w" , packetmachine .Name , err )
489
490
}
490
491
491
492
device = dev
@@ -499,9 +500,9 @@ func (r *PacketMachineReconciler) reconcileDelete(ctx context.Context, machineSc
499
500
500
501
apiRequest := r .PacketClient .DevicesApi .DeleteDevice (ctx , device .GetId ()).ForceDelete (force )
501
502
if _ , err := apiRequest .Execute (); err != nil { //nolint:bodyclose // see https://github.com/timakin/bodyclose/issues/42
502
- return ctrl. Result {}, fmt .Errorf ("failed to delete the machine: %w" , err )
503
+ return fmt .Errorf ("failed to delete the machine: %w" , err )
503
504
}
504
505
505
506
controllerutil .RemoveFinalizer (packetmachine , infrav1 .MachineFinalizer )
506
- return ctrl. Result {}, nil
507
+ return nil
507
508
}
0 commit comments