8000 refactor(reconciler): run batcher and kueuesync as manager runnables by VLukiantsev · Pull Request #1024 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

refactor(reconciler): run batcher and kueuesync as manager runnables - #1024

Merged
VLukiantsev merged 1 commit into
feat/reconciler-manager-optionsfrom
refactor/reconciler-manager-runnables
Oct 2, 2026
Merged

VLukiantsev merged 1 commit into
feat/reconciler-manager-optionsfrom
refactor/reconciler-manager-runnables

Conversation

@VLukiantsev
@VLukiantsev VLukiantsev commented Sep 29, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Registers the update batcher and the kueuesync position-in-queue loop as controller-runtime manager runnables, so both start after caches sync and stop with the controllers on shutdown.

Stack: Part 4/5 of stack; depends on #1023.

Motivation & Context

Background loops were started in two ad-hoc places: the JobSet controller's SetupWithManager registered the batcher (coupling a shared component to one controller), and Manager.Start spawned kueuesync in a bare goroutine outside the controller-runtime lifecycle with its own cancellation handling. A single, manager-owned lifecycle removes that duplication and ordering risk.

Key Changes

  • New addBackgroundRunnables step in registerControllers adds both loops via manager.RunnableFunc.
  • registerControllers returns only the batcher; Manager no longer tracks the kueuesync reconciler; Manager.Start delegates to the controller-runtime manager.
  • The JobSet controller no longer registers the batcher runnable.
  • Tests: fakeControllerManager records added runnables; TestAddBackgroundRunnables covers success (two runnables), kueuesync construction failure and manager Add failure.

Assumptions

  • kueuesync behaviour is unchanged; only its lifecycle is now manager-owned (it starts after cache sync rather than immediately) — the loop reads from the cache and is periodic — a short delay in the first position-in-queue update at startup if wrong.
  • The internal mirror of the reconciler is not updated — the copies diverge until synced.
  • Coverage % not measured — bazel coverage yields empty reports for compat_go_* targets (pre-existing tooling limitation).

Verification & Testing

Related Issues / Bugs

N/A

TAG=agy
CONV=3b97e4d5-890c-4d84-b18b-da955eeb96cd

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the registration of background runnables (the update batcher and kueue sync) by registering them directly with the controller-runtime manager, allowing them to start and stop in sync with the controllers. Feedback suggests replacing the deprecated manager.RunnableFunc with a custom runnable adapter to ensure compatibility with newer versions of the controller-runtime library.

Comment thread cmd/reconciler/controllers.go Resolved
@VLukiantsev
VLukiantsev force-pushed the refactor/reconciler-manager-runnables branch from 7d4a3fb to b97a72f Compare September 29, 2026 09:58
@VLukiantsev
VLukiantsev added this pull request to stack #1028 September 29, 2026 10:09
@VLukiantsev
VLukiantsev force-pushed the refactor/reconciler-manager-runnables branch from b97a72f to 32cad5e Compare September 29, 2026 10:12
@VLukiantsev
VLukiantsev force-pushed the refactor/reconciler-manager-runnables branch 2 times, most recently from 53e2ff8 to 95512c9 Compare September 29, 2026 11:10
@VLukiantsev
VLukiantsev marked this pull request as ready for review September 29, 2026 11:16
@github-actions
github-actions Bot requested a review from janzak-dev September 29, 2026 11:17
janzak-dev
janzak-dev previously approved these changes Sep 29, 2026
@VLukiantsev
VLukiantsev force-pushed the refactor/reconciler-manager-runnables branch from 95512c9 to bffd7a7 Compare September 29, 2026 12:40
@VLukiantsev
VLukiantsev force-pushed the refactor/reconciler-manager-runnables branch from bffd7a7 to 0683b7d Compare September 29, 2026 12:59
github-actions[bot]
github-actions Bot previously approved these changes Sep 29, 2026
@github-actions github-actions Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Incremental PR Approval

Clean rebase detected with zero semantic patch lines changed.

Preserving prior approval by @janzak-dev on commit bffd7a7.

Background loops were started in two ad-hoc places: the JobSet
controller's SetupWithManager registered the update batcher as a
runnable (coupling an unrelated shared component to one controller),
and Manager.Start spawned the kueuesync position-in-queue loop in a bare
goroutine outside the controller-runtime lifecycle, with its own
cancellation handling.

Register both through a single addBackgroundRunnables step in
registerControllers via manager.RunnableFunc, so they start after the
caches sync and stop together with the controllers on shutdown.
registerControllers now returns only the batcher, the Manager no longer
tracks the kueuesync reconciler, and Manager.Start simply delegates to
the controller-runtime manager.

Tests: fakeControllerManager records added runnables; the new
TestAddBackgroundRunnables covers the success path (two runnables),
kueuesync construction failure, and manager Add failure.

TAG=agy
CONV=01d33a7b-38ec-4d7e-bfc6-b0e56c70a294
@github-actions github-actions Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Incremental PR Approval

Clean rebase detected with zero semantic patch lines changed.

Preserving prior approval by @janzak-dev on commit bffd7a7.

@VLukiantsev
VLukiantsev added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit 3a6bf90 Oct 2, 2026
19 of 21 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

0