Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit e61b829

Browse files
committed
feat: add emlb deletion to machien controller
Signed-off-by: Chris Privitere <[email protected]>
1 parent ba20443 commit e61b829

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

controllers/packetmachine_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,21 @@ func (r *PacketMachineReconciler) reconcileDelete(ctx context.Context, machineSc
537537
device = dev
538538
}
539539

540-
// We should never get there but this is a safetly check
540+
// We should never get there but this is a safety check
541541
if device == nil {
542542
controllerutil.RemoveFinalizer(packetmachine, infrav1.MachineFinalizer)
543543
return fmt.Errorf("%w: %s", errMissingDevice, packetmachine.Name)
544544
}
545545

546+
if machineScope.PacketCluster.Spec.VIPManager == emlb.EMLBVIPID {
547+
// Create new EMLB object
548+
lb := emlb.NewEMLB(r.PacketClient.GetConfig().DefaultHeader["X-Auth-Token"], machineScope.PacketCluster.Spec.ProjectID, packetmachine.Spec.Metro)
549+
550+
if err := lb.DeleteLoadBalancerOrigin(ctx, machineScope); err != nil {
551+
return fmt.Errorf("failed to delete load balancer origin: %w", err)
552+
}
553+
}
554+
546555
apiRequest := r.PacketClient.DevicesApi.DeleteDevice(ctx, device.GetId()).ForceDelete(force)
547556
if _, err := apiRequest.Execute(); err != nil { //nolint:bodyclose // see https://github.com/timakin/bodyclose/issues/42
548557
return fmt.Errorf("failed to delete the machine: %w", err)

0 commit comments

Comments
 (0)