Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
fix: prepare settings before invoking FLB API (#286)
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Yang <reaver@flomesh.io>
  • Loading branch information
reaver-flomesh committed Jun 27, 2023
1 parent 0e3ad29 commit d12812f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions controllers/flb/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,8 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

if flb.IsFlbEnabled(svc, r.K8sAPI) {
klog.V(5).Infof("Type of service %s/%s is LoadBalancer", req.Namespace, req.Name)
r.cache[req.NamespacedName] = svc.DeepCopy()

if svc.DeletionTimestamp != nil {
result, err := r.deleteEntryFromFLB(ctx, svc)
if err != nil {
return result, err
}

delete(r.cache, req.NamespacedName)
return ctrl.Result{}, nil
}

r.cache[req.NamespacedName] = svc.DeepCopy()
mc := r.ControlPlaneConfigStore.MeshConfig.GetConfig()

secrets, err := r.K8sAPI.Client.CoreV1().
Expand Down Expand Up @@ -371,6 +361,16 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}
}

if svc.DeletionTimestamp != nil {
result, err := r.deleteEntryFromFLB(ctx, svc)
if err != nil {
return result, err
}

delete(r.cache, req.NamespacedName)
return ctrl.Result{}, nil
}

klog.V(5).Infof("Annotations of service %s/%s is %v", svc.Namespace, svc.Name, svc.Annotations)
if newAnnotations := r.computeServiceAnnotations(svc); newAnnotations != nil {
svc.Annotations = newAnnotations
Expand Down

0 comments on commit d12812f

Please sign in to comment.