Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete RBS annotations as a last step on garbage collection #1743

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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