Skip to content

Commit

Permalink
apiextensions/claim: add context to claim Waiting condition
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 Sep 8, 2023
1 parent 63b1c99 commit 018d42e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions internal/controller/apiextensions/claim/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package claim

import (
"context"
"fmt"
"time"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -546,13 +547,31 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco

cm.SetConditions(xpv1.ReconcileSuccess())

if !resource.IsConditionTrue(cp.GetCondition(xpv1.TypeReady)) {
log.Debug("Composite resource is not yet ready")
record.Event(cm, event.Normal(reasonBind, "Composite resource is not yet ready"))
ready := cp.GetCondition(xpv1.TypeReady)
synced := cp.GetCondition(xpv1.TypeSynced)
if ready.Status != corev1.ConditionTrue {
log.Debug("Composite resource is not yet ready", "reason", ready.Reason, "message", ready.Message)
if synced.Status != corev1.ConditionTrue && synced.Reason != "" {

Check failure on line 554 in internal/controller/apiextensions/claim/reconciler.go

View workflow job for this annotation

GitHub Actions / lint

ifElseChain: rewrite if-else to switch statement (gocritic)
msg := ready.Message
if msg == "" {
msg = string(ready.Reason)
}
record.Event(cm, event.Normal(reasonBind, fmt.Sprintf("%s: %s", Waiting().Message, msg)))
cm.SetConditions(Waiting().WithMessage(fmt.Sprintf("%s: %s", Waiting().Message, msg)))
} else if ready.Reason != "" {
msg := ready.Message
if msg == "" {
msg = string(ready.Reason)
}
record.Event(cm, event.Normal(reasonBind, fmt.Sprintf("%s: %s", Waiting().Message, msg)))
cm.SetConditions(Waiting().WithMessage(fmt.Sprintf("%s: %s", Waiting().Message, msg)))
} else {
record.Event(cm, event.Normal(reasonBind, Waiting().Message))
cm.SetConditions(Waiting().WithMessage(Waiting().Message))
}

// We should be watching the composite resource and will have a
// request queued if it changes, so no need to requeue.
cm.SetConditions(Waiting())
return reconcile.Result{}, errors.Wrap(r.client.Status().Update(ctx, cm), errUpdateClaimStatus)
}

Expand Down

0 comments on commit 018d42e

Please sign in to comment.