@@ -247,20 +247,16 @@ func (e *EMLB) DeleteLoadBalancer(ctx context.Context, clusterScope *scope.Clust
247247 return nil
248248 }
249249
250- // Fetch the Load Balancer object.
251- // Skip if 404, otherwise error
252- lb , resp , err := e .getLoadBalancer (ctx , lbID )
253- if err != nil && (resp .StatusCode != http .StatusNotFound ) {
254- log .Error (err , "unexpected error while loading the loadbalancer object, cannot proceed with deletion" )
255- return err
256- }
257-
258250 log .Info ("Deleting EMLB" , "Cluster Metro" , e .metro , "Cluster Name" , clusterName , "Project ID" , e .projectID , "Load Balancer ID" , lbID )
259251
260- resp , err = e .deleteLoadBalancer (ctx , lb .GetId ())
261- if err != nil && (resp .StatusCode != http .StatusNotFound ) {
262- log .Error (err , "LB Delete Failed" , "EMLB ID" , lb .GetId (), "Response Body" , resp .Body )
263- return err
252+ resp , err := e .deleteLoadBalancer (ctx , lbID )
253+ if err != nil {
254+ if resp .StatusCode == http .StatusNotFound {
255+ return nil
256+ } else {
257+ log .Error (err , "LB Delete Failed" , "EMLB ID" , lbID , "Response Body" , resp .Body )
258+ return err
259+ }
264260 }
265261
266262 return nil
@@ -279,19 +275,16 @@ func (e *EMLB) DeleteLoadBalancerOrigin(ctx context.Context, machineScope *scope
279275 return fmt .Errorf ("no Equinix Metal Load Balancer Pool found in machine's annotations" )
280276 }
281277
282- // Fetch the Load Balancer Pool object.
283- lbPool , resp , err := e .getLoadBalancerPool (ctx , lbPoolID )
284- if err != nil && (resp .StatusCode != http .StatusNotFound ) {
285- log .Error (err , "unexpected error while loading the loadbalancer pool object, cannot proceed with deletion" )
286- return err
287- }
288-
289278 log .Info ("Deleting EMLB Pool" , "Cluster Metro" , e .metro , "Cluster Name" , clusterName , "Project ID" , e .projectID , "Pool ID" , lbPoolID )
290279
291- resp , err = e .deletePool (ctx , lbPool .GetId ())
292- if err != nil && (resp .StatusCode != http .StatusNotFound ) {
293- log .Error (err , "LB Pool Delete Failed" , "Pool ID" , lbPool .GetId (), "Response Body" , resp .Body )
294- return err
280+ resp , err := e .deletePool (ctx , lbPoolID )
281+ if err != nil {
282+ if resp .StatusCode != http .StatusNotFound {
283+ return nil
284+ } else {
285+ log .Error (err , "LB Pool Delete Failed" , "Pool ID" , lbPoolID , "Response Body" , resp .Body )
286+ return err
287+ }
295288 }
296289
297290 return nil
0 commit comments