Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Mar 12, 2024
1 parent b929466 commit 7bb9e7f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controllers/groupsync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (r *GroupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
l := log.FromContext(ctx)
l.Info("Reconciling Group")

finalizerName := UpstreamFinalizerPrefix + r.ControlAPIFinalizerZoneName

var members []controlv1.UserRef
var upstream client.Object

Expand Down Expand Up @@ -90,13 +92,17 @@ func (r *GroupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, err
}

if controllerutil.RemoveFinalizer(upstream, UpstreamFinalizerPrefix+r.ControlAPIFinalizerZoneName) {
l.Info("Group deleted")

if controllerutil.RemoveFinalizer(upstream, finalizerName) {
if err := r.ForeignClient.Update(ctx, upstream); err != nil {
l.Error(err, "unable to remove finalizer from upstream")
return ctrl.Result{}, err
}
}

l.Info("Finalizer removed from upstream", "finalizer", finalizerName)

return ctrl.Result{}, nil
}

Expand All @@ -112,12 +118,14 @@ func (r *GroupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
l.Error(err, "unable to create or update (%q) Group", op)
return ctrl.Result{}, err
}
l.Info("Group reconciled", "operation", op)

if controllerutil.AddFinalizer(upstream, UpstreamFinalizerPrefix+r.ControlAPIFinalizerZoneName) {
if controllerutil.AddFinalizer(upstream, finalizerName) {
if err := r.ForeignClient.Update(ctx, upstream); err != nil {
l.Error(err, "unable to add finalizer to upstream")
return ctrl.Result{}, err
}
l.Info("Finalizer added to upstream", "finalizer", finalizerName)
}

return ctrl.Result{}, nil
Expand Down

0 comments on commit 7bb9e7f

Please sign in to comment.