Skip to content

Commit

Permalink
calling generateVAPB after constraint is enforced
Browse files Browse the repository at this point in the history
Signed-off-by: Jaydip Gabani <[email protected]>
  • Loading branch information
JaydipGabani committed Nov 5, 2024
1 parent 66626cf commit a7ae597
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pkg/controller/constraint/constraint_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,6 @@ func (r *ReconcileConstraint) Reconcile(ctx context.Context, request reconcile.R
logAddition(r.log, instance, enforcementAction)
}

requeueAfter, err := r.generateVAPB(ctx, enforcementAction, instance, status)
if err != nil {
return reconcile.Result{RequeueAfter: requeueAfter}, err
}
if requeueAfter != time.Duration(0) {
log.Info("requeueing after", "requeueAfter", requeueAfter)
return reconcile.Result{RequeueAfter: requeueAfter}, nil
}

status.Status.Enforced = true
if err = r.writer.Update(ctx, status); err != nil {
return reconcile.Result{Requeue: true}, nil
Expand All @@ -334,6 +325,14 @@ func (r *ReconcileConstraint) Reconcile(ctx context.Context, request reconcile.R
status: metrics.ActiveStatus,
})
reportMetrics = true
requeueAfter, err := r.generateVAPB(ctx, enforcementAction, instance, status)
if err != nil {
return reconcile.Result{RequeueAfter: requeueAfter}, err
}
if requeueAfter != time.Duration(0) {
log.Info("requeueing after", "requeueAfter", requeueAfter)
return reconcile.Result{RequeueAfter: requeueAfter}, nil
}
} else {
r.log.Info("handling constraint delete", "instance", instance)
if _, err := r.cfClient.RemoveConstraint(ctx, instance); err != nil {
Expand Down

0 comments on commit a7ae597

Please sign in to comment.