-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Concurrent resource discovery for the same context can race and overwrite fresher registry data with older results.
Affected code
src/kubernetes/client.rs(discover_resources_for_context)
Root cause
discover_resources_for_context has no per-context synchronization.
Multiple in-flight discoveries for same context can run concurrently and each performs a blind final write:
registries.insert(context, CachedRegistry::new(registry))
The last finisher wins, regardless of freshness/force intent.
Impact
- Potential stale/older registry replacing fresher one.
- Non-deterministic table metadata under concurrent operations.
- Correctness/freshness issue (higher priority).
Proposed fix
- Serialize discovery per context using per-context async mutex/lock.
- Or apply generation/epoch guard so older discovery results cannot overwrite newer ones.
- Keep cross-context discovery parallel (only serialize within each context key).
Tests to add
- Simulate concurrent force and non-force discovery for same context; ensure final registry corresponds to freshest/force result.
- Regression test for deterministic final registry under concurrent discovery calls.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels