-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
get_or_create_client has a check-then-create race for the same context.
Affected code
src/kubernetes/client.rs(get_or_create_client)
Root cause
Current flow:
- read lock check for existing client
- release lock
- create client
- acquire write lock and insert
Parallel callers for the same context can both miss step 1 and both create clients; last insert wins.
Impact
- Primarily inefficiency/redundant work (duplicate kube client creation/handshake).
- Can add startup latency under parallel discovery.
- Lower correctness risk than discovery overwrite race, but still undesirable.
Proposed fix
- Add a second check under write lock before insert (double-checked locking pattern).
- Optionally use per-context once/mutex to guarantee single creation path.
Tests to add
- Concurrent calls to
get_or_create_clientfor same context should create at most one underlying client. - Verify all callers receive a valid client and no errors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels