Skip to content

Commit

Permalink
Merge pull request #1743 from panslava/delete-rbs-annotations-last
Browse files Browse the repository at this point in the history
Delete RBS annotations as a last step on garbage collection
  • Loading branch information
k8s-ci-robot authored Jun 28, 2022
2 parents f3493e5 + d982a33 commit ed766c5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/l4lb/l4netlbcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,12 @@ func (lc *L4NetLBController) garbageCollectRBSNetLB(key string, svc *v1.Service)
return result
}

// Remove LB annotations from the Service when processing the finalizer.
if err := deleteL4RBSAnnotations(lc.ctx, svc); err != nil {
lc.ctx.Recorder(svc.Namespace).Eventf(svc, v1.EventTypeWarning, "DeleteLoadBalancer",
"Error removing resource annotations: %v: %v", err)
result.Error = fmt.Errorf("Failed to reset resource annotations, err: %w", err)
// Try to delete instance group, instancePool.DeleteInstanceGroup ignores errors if resource is in use or not found.
// TODO(cezarygerard) replace with multi-IG management
if err := lc.instancePool.DeleteInstanceGroup(lc.namer.InstanceGroup()); err != nil {
lc.ctx.Recorder(svc.Namespace).Eventf(svc, v1.EventTypeWarning, "DeleteInstanceGroupFailed",
"Error deleting delete Instance Group from L4 External LoadBalancer, err: %v", err)
result.Error = fmt.Errorf("Failed to delete Instance Group, err: %w", err)
return result
}

Expand All @@ -514,12 +515,11 @@ func (lc *L4NetLBController) garbageCollectRBSNetLB(key string, svc *v1.Service)
return result
}

// Try to delete instance group, instancePool.DeleteInstanceGroup ignores errors if resource is in use or not found.
// TODO(cezarygerard) replace with multi-IG management
if err := lc.instancePool.DeleteInstanceGroup(lc.namer.InstanceGroup()); err != nil {
lc.ctx.Recorder(svc.Namespace).Eventf(svc, v1.EventTypeWarning, "DeleteInstanceGroupFailed",
"Error deleting delete Instance Group from L4 External LoadBalancer, err: %v", err)
result.Error = fmt.Errorf("Failed to delete Instance Group, err: %w", err)
// IMPORTANT: Remove LB annotations from the Service LAST, cause changing service fields are emitted as service update to other controllers
if err := deleteL4RBSAnnotations(lc.ctx, svc); err != nil {
lc.ctx.Recorder(svc.Namespace).Eventf(svc, v1.EventTypeWarning, "DeleteLoadBalancer",
"Error removing resource annotations: %v: %v", err)
result.Error = fmt.Errorf("Failed to reset resource annotations, err: %w", err)
return result
}

Expand Down

0 comments on commit ed766c5

Please sign in to comment.