Skip to content

Improve debouncer#100

Open
karolz-ms wants to merge 5 commits intomainfrom
dev/karolz/debouncer
Open

Improve debouncer#100
karolz-ms wants to merge 5 commits intomainfrom
dev/karolz/debouncer

Conversation

@karolz-ms
Copy link
Collaborator

While working on some other code I realized our debouncer(s) suffer from two issues:

  1. The arg parameter to Run() method just does not make sense. There is no reasonable way to account for different values of arg when multiple Run() invocation are debounced into a single runner run.
  2. Any new Run() invocations that happen when the runner is running should be associated with a new debounce cycle. The reason is a common scenario where the invoker of Run() sets up some shared state and then expect the runner to consume it.

This PR fixes these two issues.

This parameter does not make sense--there is no way to account for different values of the parameter when multiple invocations are "squished" into one by debouncing.
This covers the common use case where Run() callers set up some state that the runner function subsequently acts upon.
@karolz-ms karolz-ms requested review from Copilot, danegsta and joperezr and removed request for Copilot March 20, 2026 16:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the “debounce last” utilities to remove the ambiguous arg passed to Run() and to ensure calls made while a runner/action is executing start a new debounce cycle.

Changes:

  • Refactors DebounceLast and DebounceLastAction to accept zero-arg runners/actions and to track per-run state.
  • Updates controller-level reconciler debouncing to match the new action debouncer API.
  • Extends/updates tests to validate new execution-cycle behavior and to remove argument-based expectations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/resiliency/debounce_last.go Refactors debouncer to zero-arg runner and per-run state tracking.
pkg/resiliency/debounce_last_action.go Refactors action debouncer similarly, with per-run state and zero-arg action.
pkg/resiliency/debounce_last_test.go Updates tests for new API and adds coverage for “Run during execution starts new run”.
pkg/resiliency/debounce_last_action_test.go Updates action tests for new API and adds analogous execution-cycle test.
controllers/reconciler_debouncer.go Adapts reconciler debouncer to the new DebounceLastAction API (no per-call args).
controllers/reconciler_base.go Updates base reconciler to use the new reconciler debouncer interface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

extensions := []DcpExtension{}

for _, extDir := range extDirs {
if _, statErr := os.Stat(extDir); statErr != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unrelated to debouncer changes--just a small fix for unnecessary error I saw in the logs.

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