Skip to content

Commit

Permalink
Expose an event when restart nginx for certificate reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Sep 5, 2024
1 parent bd6c3ee commit 1f26996
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 8 additions & 1 deletion controllers/rpaasinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func (r *RpaasInstanceReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

if certificatesHasChanges {
msg := "RPaaS controller has updated this resource due a certificate change"
logger.Info(msg)
r.EventRecorder.Event(instance, corev1.EventTypeWarning, "RpaasInstanceCertificatesChanged", msg)
reservation.Cancel()
} else if listOfChanges := getChangesList(changes); len(listOfChanges) > 0 {
if systemRollout {
Expand All @@ -231,7 +234,11 @@ func (r *RpaasInstanceReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

if err = r.refreshStatus(ctx, instance, instanceHash, nginx); err != nil {
return ctrl.Result{}, err
reservation.Cancel()
return ctrl.Result{
Requeue: true,
RequeueAfter: time.Second * 10,
}, err
}

return ctrl.Result{}, nil
Expand Down
16 changes: 15 additions & 1 deletion controllers/system_rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ func (r *systemRolloutRateLimiter) Reserve() (allowed bool, reservation SystemRo
return false, nil
}

return true, rateLimitReservation
return true, &onceReservation{Reservation: rateLimitReservation}
}

type onceReservation struct {
*rate.Reservation
canceled bool
}

func (r *onceReservation) Cancel() {
if r.canceled {
return
}

r.Reservation.Cancel()
r.canceled = true
}

type noopReservation struct{}
Expand Down

0 comments on commit 1f26996

Please sign in to comment.