Skip to content

Add per-resource poll interval and reconcile-request annotations#982

Merged
adamwg merged 1 commit intocrossplane:mainfrom
yordis:yordis/resc-poll-interval
Apr 21, 2026
Merged

Add per-resource poll interval and reconcile-request annotations#982
adamwg merged 1 commit intocrossplane:mainfrom
yordis:yordis/resc-poll-interval

Conversation

@yordis
Copy link
Copy Markdown
Contributor

@yordis yordis commented Apr 20, 2026

  • Companion to Add per-resource poll interval and reconcile-now annotations crossplane#7239 which implemented the XR side
  • Operators managing stable, rarely-changing resources (databases, DNS zones) pay unnecessary API costs with the global poll interval, while dynamic resources need faster drift detection — there is no middle ground today
  • Providers inherit both features upon upgrading their crossplane-runtime dependency with no code changes, because managed resources that embed ObservedStatus automatically satisfy the reconcile-request tracker interface

@yordis yordis requested a review from a team as a code owner April 20, 2026 22:36
@yordis yordis requested a review from adamwg April 20, 2026 22:36
@yordis yordis force-pushed the yordis/resc-poll-interval branch from e191129 to e671e68 Compare April 20, 2026 22:41
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@yordis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 30 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 30 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 875d9879-51ed-4dae-aad6-d056d1f10825

📥 Commits

Reviewing files that changed from the base of the PR and between e191129 and 727ced0.

⛔ Files ignored due to path filters (4)
  • go.mod is excluded by none and included by none
  • go.sum is excluded by !**/*.sum and included by none
  • gomod2nix.toml is excluded by none and included by none
  • pkg/resource/fake/mocks.go is excluded by !**/fake/** and included by **/*.go
📒 Files selected for processing (2)
  • pkg/reconciler/managed/reconciler.go
  • pkg/reconciler/managed/reconciler_modern_test.go
📝 Walkthrough

Walkthrough

This PR introduces reconciliation request tracking via a new interface that records when reconcile requests are handled, and adds configurable minimum poll intervals with per-resource annotation overrides to the managed resource reconciler.

Changes

Cohort / File(s) Summary
Reconciler Core Implementation
pkg/reconciler/managed/reconciler.go
Added reconcileRequestTracker interface for tracking last-handled reconcile tokens, introduced effectivePollInterval() helper to enforce minimum poll intervals from per-resource annotations, added WithMinPollInterval() option, and integrated reconcile request handling with event emission when token values differ.
Reconciler Tests
pkg/reconciler/managed/reconciler_modern_test.go
Added three comprehensive test cases: TestEffectivePollInterval (validates annotation override clamping), TestReconcilePollIntervalAnnotation (verifies poll interval is applied to requeue delays), and TestReconcileRequestAnnotation (verifies reconcile request token tracking and deduplication).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: adding per-resource poll interval and reconcile-request annotations, which directly matches the changeset.
Description check ✅ Passed The description relates the changes to the broader context, explaining the motivation and benefits of the per-resource poll interval and reconcile-request annotations.
Breaking Changes ✅ Passed The PR adds only new public API (WithMinPollInterval function) and internal implementation details with no removals, renames, signature changes, or breaking behavior changes to existing exported code.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/reconciler/managed/reconciler_modern_test.go`:
- Around line 2856-3082: The test doesn't assert the full reconcile.Result and
lacks a case for a poll-interval annotation below the configured minimum; update
TestReconcilePollIntervalAnnotation to (1) extend the case struct to include
minPollInterval, pass it to WithMinPollInterval(...) when constructing the
Reconciler, and add a case "AnnotationBelowMinimumClampsToMin" with an
annotation shorter than minPollInterval expecting Reconcile.Result.RequeueAfter
~ minPollInterval and Requeue==false; (2) replace the current partial
RequeueAfter comparison with a full cmp.Diff on the entire reconcile.Result (use
cmpopts.EquateErrors() for any error comparisons) so unexpected Requeue bools or
other fields are caught; and (3) ensure the effectivePollInterval and
WithMinPollInterval behavior is exercised by referencing effectivePollInterval
in assertions indirectly via the Reconcile call on the NewReconciler instance.

In `@pkg/reconciler/managed/reconciler.go`:
- Around line 981-991: The reconcile-request token is being set on the managed
object early and can be lost by later full-object Update paths; instead, ensure
the token is persisted at the moment you persist status by moving the
SetLastHandledReconcileAt write into the status-update wrapper (use/update the
updateStatus() helper) so the token is applied to the in-memory status just
before calling Status().Update. Concretely: change code that currently calls
tracker.SetLastHandledReconcileAt(token) near the top to only record the event
(record.Event with reasonReconcileRequestHandled) and defer updating
GetLastHandledReconcileAt/SetLastHandledReconcileAt until inside the
updateStatus() function (and update all status persistence callsites to use
updateStatus()), ensuring meta.GetReconcileRequest, reconcileRequestTracker,
tracker.GetLastHandledReconcileAt and tracker.SetLastHandledReconcileAt are used
to detect/assign the token immediately prior to the Status().Update call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 12824fb8-3530-4159-a891-917b6c366abf

📥 Commits

Reviewing files that changed from the base of the PR and between 221d926 and e191129.

⛔ Files ignored due to path filters (3)
  • go.mod is excluded by none and included by none
  • go.sum is excluded by !**/*.sum and included by none
  • pkg/resource/fake/mocks.go is excluded by !**/fake/** and included by **/*.go
📒 Files selected for processing (2)
  • pkg/reconciler/managed/reconciler.go
  • pkg/reconciler/managed/reconciler_modern_test.go

Comment thread pkg/reconciler/managed/reconciler_modern_test.go
Comment thread pkg/reconciler/managed/reconciler.go Outdated
@yordis yordis force-pushed the yordis/resc-poll-interval branch from e671e68 to e8f2b84 Compare April 20, 2026 22:48
…nnotations

Fixes crossplane/crossplane#7204

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Copy link
Copy Markdown
Member

@adamwg adamwg left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for seeing this through!

@adamwg adamwg merged commit a27ec88 into crossplane:main Apr 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants