Skip to content

Commit

Permalink
Merge pull request #5304 from sttts/sttts-usage-debug-output
Browse files Browse the repository at this point in the history
controller/usage: remove debug output
  • Loading branch information
phisco committed Feb 1, 2024
2 parents 5bdeb1a + e494fd9 commit 7b86642
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/controller/apiextensions/usage/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"
"time"

"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
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 All @@ -223,8 +225,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
return reconcile.Result{}, err
}

r.record.Event(u, event.Normal(reasonResolveSelectors, "Selectors resolved, if any."))

of := u.Spec.Of
by := u.Spec.By

Expand Down Expand Up @@ -406,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 !cmp.Equal(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 7b86642

Please sign in to comment.