@@ -80,7 +80,7 @@ func (s *Service) Reconcile(ctx context.Context) error {
8080 return fmt .Errorf ("failed to ensure control-plane lbs: %w" , err )
8181 }
8282
83- if err := s .ensureControlPlaneLBsACL (ctx , lbs , instanceIPsToStrings (server .PublicIPs )); err != nil {
83+ if err := s .ensureControlPlaneLBsACL (ctx , lbs , instanceIPsToStrings (server .PublicIPs ), false ); err != nil {
8484 return fmt .Errorf ("failed to ensure control-plane lbs acls: %w" , err )
8585 }
8686
@@ -127,7 +127,7 @@ func (s *Service) Delete(ctx context.Context) error {
127127 return err
128128 }
129129
130- if err := s .ensureControlPlaneLBsACL (ctx , lbs , nil ); err != nil && ! client .IsNotFoundError (err ) {
130+ if err := s .ensureControlPlaneLBsACL (ctx , lbs , nil , true ); err != nil && ! client .IsNotFoundError (err ) {
131131 return fmt .Errorf ("failed to ensure control-plane lbs acls: %w" , err )
132132 }
133133
@@ -413,7 +413,7 @@ func (s *Service) ensureControlPlaneLBs(ctx context.Context, lbs []*lb.LB, nodeI
413413 continue
414414 }
415415
416- backend , err := s .ScalewayClient .FindBackend (ctx , loadbalancer .Zone , loadbalancer .ID , s . Cluster . ResourceName () )
416+ backend , err := s .ScalewayClient .FindBackend (ctx , loadbalancer .Zone , loadbalancer .ID , servicelb . BackendName )
417417 if err != nil {
418418 return err
419419 }
@@ -433,14 +433,19 @@ func (s *Service) ensureControlPlaneLBs(ctx context.Context, lbs []*lb.LB, nodeI
433433 return nil
434434}
435435
436- func (s * Service ) ensureControlPlaneLBsACL (ctx context.Context , lbs []* lb.LB , publicIPs []string ) error {
436+ func (s * Service ) ensureControlPlaneLBsACL (ctx context.Context , lbs []* lb.LB , publicIPs []string , delete bool ) error {
437437 for _ , loadbalancer := range lbs {
438438 if loadbalancer .Status == lb .LBStatusDeleting {
439439 continue
440440 }
441441
442- frontend , err := s .ScalewayClient .FindFrontend (ctx , loadbalancer .Zone , loadbalancer .ID , s . Cluster . ResourceName () )
442+ frontend , err := s .ScalewayClient .FindFrontend (ctx , loadbalancer .Zone , loadbalancer .ID , servicelb . FrontendName )
443443 if err != nil {
444+ // If the frontend is not found, we can skip it when reconciling a deletion.
445+ if delete && client .IsNotFoundError (err ) {
446+ continue
447+ }
448+
444449 return err
445450 }
446451
0 commit comments