Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion reconcilers/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ func (r *ResourceReconciler[T]) Reconcile(ctx context.Context, req Request) (Res
result, err := r.AfterReconcile(ctx, req, AggregateResults(beforeResult, reconcileResult), err)
if errors.Is(err, ErrQuiet) {
// suppress error, while forcing a requeue
if result.RequeueAfter > 0 { // honor requeue after returned by reconciler
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be okay to add.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a use case below and I really think this is worth to add.

return result, nil
}
return Result{Requeue: true}, nil
}
return result, err
Expand Down Expand Up @@ -381,7 +384,11 @@ func (r *ResourceReconciler[T]) reconcileOuter(ctx context.Context, req Request)
}

// Suppress result. Let the informer discover the resource mutation and requeue. Requeueing
// now may result in re-processing a stale cache.
// now may result in re-processing a stale cache. Honor the requeue after if it was set.
if result.RequeueAfter > 0 {
return result, nil
}

return Result{}, nil
}

Expand Down
5 changes: 4 additions & 1 deletion reconcilers/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ func TestResourceReconciler(t *testing.T) {
resource.Status.Fields = map[string]string{}
}
resource.Status.Fields["Reconciler"] = "ran"
// the result is ignored because the status is updated
// the result is honored
return reconcilers.Result{RequeueAfter: 10}, nil
},
}
Expand All @@ -974,6 +974,9 @@ func TestResourceReconciler(t *testing.T) {
rtesting.NewEvent(givenResource, scheme, corev1.EventTypeNormal, "StatusUpdated",
`Updated status`),
},
ExpectedResult: reconcile.Result{
RequeueAfter: 10,
},
ExpectStatusUpdates: []client.Object{
givenResource.StatusDie(func(d *dies.TestResourceStatusDie) {
d.AddField("Reconciler", "ran")
Expand Down
Loading