Skip to content

🐛 fix(controller): make inventory store source Start non-blocking (DR-FIND-01) - #143

Merged
konih merged 1 commit into
mainfrom
dr-find-01-inventory-source-nonblocking
Jul 31, 2026
Merged

konih merged 1 commit into
mainfrom
dr-find-01-inventory-source-nonblocking

Conversation

@konih

@konih konih commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

DR-FIND-01 (P0) — KollectInventory controller never starts workers

Root cause. inventoryNamespaceSource.Start ran a forever for/select loop and only returned on ctx.Done(). controller-runtime waits for every raw-source Start (wired via WatchesRawSource at kollectinventory_controller.go:637) to return before starting a controller's workers — so the namespaced KollectInventory controller never started workers, inventory CRs never reconciled/exported. Reproduced on driving-range v0.9.0 and v0.10.0 (dr-20260731-80aef1). KollectClusterInventory was unaffected (it doesn't use this source).

Fix. Arm the store subscription synchronously on the caller goroutine, run the coalescing dispatch loop in a goroutine, and return nil immediately. The unsubscribe defer moves into the goroutine; the nil-guard branch no longer blocks on ctx.Done(). Timer/coalesce (50ms) semantics unchanged.

Tests. nilDependenciesReturnsPromptly asserts prompt return under an un-cancelled context (old code hangs → fails). enqueuesInventoryRequests now calls Start directly (no manual goroutine) then Upserts with no sleep — proving Start is non-blocking and the subscription is armed before it returns. Both discriminate the regression.

Gates. go build ✅ · controller envtest suite (43 specs) ✅ · go test -race ✅ race-clean · go vet ✅ · custom make lint 0 issues ✅.

Independent review: APPROVE, no P0/P1 (3 P3 optional follow-ups: dead-but-harmless mutex, add a bounded per-test timeout guard, add a dedicated 'workers start' envtest).

inventoryNamespaceSource.Start ran a forever select loop and only returned
on ctx.Done(). controller-runtime waits for every raw-source Start to return
before starting a controller's workers, so the namespaced KollectInventory
controller never started workers and inventory CRs never reconciled/exported
(DR-FIND-01, reproduced on driving-range v0.9.0 and v0.10.0).

Arm the store subscription synchronously, then run the coalescing dispatch
loop in a goroutine and return nil immediately. Move the unsubscribe defer
into the goroutine; drop the blocking ctx.Done() wait from the nil-guard.

Tests: nil-deps now asserts prompt return under an un-cancelled context;
the enqueue test calls Start directly (no manual goroutine) then Upserts
with no sleep, proving Start is non-blocking and the subscription is armed
before it returns.
@konih
konih merged commit 519a62d into main Jul 31, 2026
23 checks passed
@konih
konih deleted the dr-find-01-inventory-source-nonblocking branch July 31, 2026 10:58
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/controller/inventory_store_source.go 92.85% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

konih added a commit that referenced this pull request Jul 31, 2026
Bump chart version/appVersion 0.10.0 -> 0.11.0 for the next minor. Unreleased
since v0.10.0: feat(netguard) NET-01 --allow-private-sinks opt-in (#146) +
fix(controller) inventory store source Start non-blocking / DR-FIND-01 (#143),
plus DR-FIND-03 lab-bootstrap docs (#148), UI-TEST-01 (#147), SEC-04j
CI-hardening (#150).
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.

1 participant