cleanup(flowcontrol): Refactor registry with generic leasing and atomic GC#2198
Conversation
Extract generic leasing and GC logic into leasing.go to reduce duplication and complexity. Inline helper methods into WithConnection. Add leasing_test.go with concurrency coverage.
|
@LukeAVanDrie: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
/assign @evacchi This is purely a cleanup effort based on some of the discussion on the flow and band leasing PRs we deferred. It should be functionally equivalent but nearly fully deduped between these resource types now. Trying to make this pattern a bit more maintainable and reduce cognitive load. |
|
@LukeAVanDrie: GitHub didn't allow me to assign the following users: evacchi, aishukamal. Note that only kubernetes-sigs members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g, LukeAVanDrie The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ay-api-inference-extension#2198) Extract generic leasing and GC logic into leasing.go to reduce duplication and complexity. Inline helper methods into WithConnection. Add leasing_test.go with concurrency coverage.
What type of PR is this?
/kind cleanup
/kind test
What this PR does / why we need it:
This PR refactors the
FlowRegistryto extract the optimistic resource leasing and garbage collection logic into a dedicated, genericleasing.gofile. Previously, the "Check-Pin-Retry" loops and "Mark-and-Sweep" GC logic were duplicated for both Flows and Priority Bands. This duplication obscured the critical concurrency safety invariants.Key Changes:
leasedStateandpinLeasedResource. This encapsulates the complex lock-free retry loops,sync.Oncehandling, etc. into a single, reusable primitive.collectLeasedResources). This ensures that Flows and Priority Bands adhere to identical lifecycle safety contracts.leasing_test.gowith unit tests for theleasedStatestate machine and a high-contention chaos test verifying that "Pin vs GC" races result in deterministic behavior without data corruption.Which issue(s) this PR fixes:
Cleanup following #2127 and #2097. Pure refactoring for maintainability, not tracked in any issue.
Does this PR introduce a user-facing change?: