Skip to content

ateapi/controlapi: process syncer events via rate-limiting workqueue - #674

Merged
Scott Funkenhauser (sfunkenhauser) merged 2 commits into
agent-substrate:mainfrom
troychiu:syncer-workqueue-refactor
Aug 5, 2026
Merged

Scott Funkenhauser (sfunkenhauser) merged 2 commits into
agent-substrate:mainfrom
troychiu:syncer-workqueue-refactor

Conversation

@troychiu

@troychiu Troy Chiu (troychiu) commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Refactors WorkerPoolSyncer to process events through a rate-limiting workqueue instead of processing them synchronously inline.

Previously, store errors during Informer event handling, such as

  • optimistic locking version conflicts (store.ErrVersionConflict)
  • create races (store.ErrAlreadyExists)
  • WorkerPool not yet present in the lister cache

were logged and dropped, leaving store state out of sync until a subsequent pod event occurred.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@troychiu

Copy link
Copy Markdown
Contributor Author

cc Eitan Yarmush (@EItanya)

@troychiu

Copy link
Copy Markdown
Contributor Author

@EItanya

Eitan Yarmush (EItanya) commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Sorry about the misunderstanding, I should've been more clear. When I said using the manager I meant to use the same reconcile style as ActorTemplate

func (r *ActorTemplateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

We have multiple reconcile styles throughout the codebase which is already confusing, and controller-runtime controllers already implement rate limiting queues.

I mentioned this to Scott Funkenhauser (@sfunkenhauser) in #728 as well

@troychiu

Copy link
Copy Markdown
Contributor Author

I agree and thanks for the context!

Eventually we would like to move WorkerPoolSyncer out of ate-api-server (#729), which requires #730. In the meantime, #728 can be temporarily solved by either this PR or #578 as a stop-gap before #730 is ready.

Given that we want a minimal stop-gap (comment), #578 might be a better candidate since it avoids introducing a new workqueue pattern here.

Let me know if you'd prefer I reopen #578 instead! Eitan Yarmush (@EItanya) Scott Funkenhauser (@sfunkenhauser)

At the same time, I am happy to help with #730

@sfunkenhauser

Copy link
Copy Markdown
Collaborator

My thought was that we can address the different reconciliation styles when moving the WorkerPoolSyncer to the ate-controller.

This PR isn't introducing a new style, and just tries to fix gaps in the existing one. I'd rather not block this improvement on reimplementing the syncer using the controller-runtime.

Eitan Yarmush (@EItanya) Feel free to push back if you disagree.

@EItanya

Copy link
Copy Markdown
Collaborator

I really don’t wanna be the person blocking this, of course I think incremental change is important. My broader point was that a lot of the logic added in this PR is done automatically by controller runtime, so if we’re going that direction we should just do it. But definitely don’t block on me if that’s not the plan, or if we plan to move away from that style.

@sfunkenhauser

Copy link
Copy Markdown
Collaborator

Eitan Yarmush (@EItanya) I appreciate you calling this out, and I agree that we should consolidate on the same reconciliation mechanism.

That being said I don't want to ask Troy Chiu (@troychiu) to re-write this PR for the third time. I don't think this PR will make it anymore difficult to switch to using controller runtime (it might actually make it easier). In the interest of incremental improvement let's get this in as in, and we can handle the controller runtime refactor when moving to ate-controller (which should hopefully happen in the next week or so).

@sfunkenhauser
Scott Funkenhauser (sfunkenhauser) merged commit de4c3db into agent-substrate:main Aug 5, 2026
11 checks passed
@EItanya

Copy link
Copy Markdown
Collaborator

So I spoke to Julian Gutierrez Oschmann (@juli4n), and it sounds like the direction is to move away from controller-runtime generally, so either way I think this was the correct direction in the end, sorry for the delay

@troychiu

Copy link
Copy Markdown
Contributor Author

Thanks Scott Funkenhauser (@sfunkenhauser) Eitan Yarmush (@EItanya)! Both of your suggestions were really helpful.

@troychiu

Copy link
Copy Markdown
Contributor Author

move away from controller-runtime generally

Do you mind providing more details?

@EItanya

Copy link
Copy Markdown
Collaborator

move away from controller-runtime generally

Do you mind providing more details?

Basically, controller-runtime is very opinionated, and contains more than is strictly necessary for many controllers. This sometimes leads to bloated controllers which don't behave exactly the way you expect. client-go machinery is slightly more complicated, but gives much more freedom to achieve the exact desired effect and performance.

Scott Funkenhauser (sfunkenhauser) pushed a commit that referenced this pull request Aug 17, 2026
Fixes #609

The startup stored-worker scan (`enqueueStoredWorkers`) returned on the
first `ListWorkers` error, skipping orphan cleanup until the next
restart. The `#674` workqueue only retries per-key reconciles, not this
initial scan, so retry the scan with capped `wait.Backoff` until it
succeeds or the context is cancelled.

- [x] Tests pass
- [ ] Appropriate changes to documentation are included in the PR
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.

3 participants