Skip to content

Commit

Permalink
controller/usage: remove repeating success event
Browse files Browse the repository at this point in the history
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
  • Loading branch information
sttts committed Jan 30, 2024
1 parent 33b2a70 commit 93ca657
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/controller/apiextensions/usage/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package usage
import (
"context"
"fmt"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -215,6 +216,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
log.Debug(errGetUsage, "error", err)
return reconcile.Result{}, errors.Wrap(xpresource.IgnoreNotFound(err), errGetUsage)
}
orig := u.DeepCopy()

if err := r.usage.resolveSelectors(ctx, u); err != nil {
log.Debug(errResolveSelectors, "error", err)
Expand Down Expand Up @@ -404,11 +406,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
}

u.Status.SetConditions(xpv1.Available())
r.record.Event(u, event.Normal(reasonUsageConfigured, "Usage configured successfully."))

// We are only watching the Usage itself but not using or used resources.
// So, we need to reconcile the Usage periodically to check if the using
// or used resources are still there.
return reconcile.Result{RequeueAfter: r.pollInterval}, errors.Wrap(r.client.Status().Update(ctx, u), errUpdateStatus)
if !reflect.DeepEqual(u, orig) {
r.record.Event(u, event.Normal(reasonUsageConfigured, "Usage configured successfully."))
return reconcile.Result{RequeueAfter: r.pollInterval}, errors.Wrap(r.client.Status().Update(ctx, u), errUpdateStatus)
}

return reconcile.Result{RequeueAfter: r.pollInterval}, nil
}

func detailsAnnotation(u *v1alpha1.Usage) string {
Expand Down

0 comments on commit 93ca657

Please sign in to comment.