Skip to content

feat(flowcontrol): Introduce ManagedQueue and Service Contracts #1174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

LukeAVanDrie
Copy link
Contributor

This work tracks #674

This PR introduces the foundational layer for the Flow Registry, which will act as the stateful control plane for managing queues and policies. It establishes the core service contracts for the system and provides the ManagedQueue, a stateful decorator that wraps queue plugins.

This work is a prerequisite for the full FlowRegistry implementation.

Key Changes:

  1. ports -> contracts Rename: The ports package has been renamed to contracts to more accurately reflect its purpose in defining the service interfaces for our "Ports and Adapters" architecture. This avoids potential confusion with network-related "ports" in the Kubernetes ecosystem.

  2. ManagedQueue Decorator: A new registry.managedQueue component is introduced. It follows the decorator pattern, wrapping a framework.SafeQueue to add critical registry-level functionality without complicating the underlying queue interface:

    • Atomic Statistics: It maintains its own atomic len and byteSize counters for high-performance, lock-free reads (useful for efficient metric reporting and capacity checking logic).
    • State Reconciliation: It uses a callback to propagate statistical deltas to its parent (the future RegistryShard), ensuring aggregated stats remain consistent.
  3. SafeQueue Interface Simplification: To support the ManagedQueue decorator, the framework.SafeQueue interface has been simplified. The Add and Remove methods no longer return the new queue state. This responsibility is now correctly handled by the ManagedQueue, making the SafeQueue contract cleaner and more focused on its core queuing logic.

Copy link

netlify bot commented Jul 16, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit b3be747
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/68796affc7dfaa00084957be
😎 Deploy Preview https://deploy-preview-1174--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 16, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 16, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @LukeAVanDrie. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 16, 2025
@LukeAVanDrie
Copy link
Contributor Author

/assign @kfswain

/assign @ahg-g

@ahg-g
Copy link
Contributor

ahg-g commented Jul 17, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 17, 2025
@ahg-g
Copy link
Contributor

ahg-g commented Jul 17, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 17, 2025
@kfswain
Copy link
Collaborator

kfswain commented Jul 17, 2025

/lgtm
/approve

Thanks Luke!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kfswain, LukeAVanDrie

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 17, 2025
This commit introduces the foundational layer for the Flow Registry, which will act as the stateful control plane for managing queues and policies. It defines the `ManagedQueue` decorator, refines the system's core service contracts, and simplifies the queue plugin interface.

The key changes are:

1.  **`ports` -> `contracts` Rename**: The `ports` package is renamed to `contracts` to more accurately reflect the "Ports and Adapters" architectural pattern and avoid confusion with network ports.

2.  **`ManagedQueue` Introduction**: A new `registry.managedQueue` component is introduced. It acts as a stateful decorator around a `framework.SafeQueue`, adding critical registry-level functionality:
    - **Atomic Statistics**: It maintains its own atomic `len` and `byteSize` counters.
    - **State Reconciliation**: It uses a callback to propagate statistical deltas to its parent (the future `RegistryShard`), ensuring aggregated stats remain consistent without locks.

3.  **`SafeQueue` Interface Simplification**: The `framework.SafeQueue` interface is simplified. The `Add` and `Remove` methods no longer return the new queue state, as this responsibility is now correctly handled by the `ManagedQueue` decorator. This makes the `SafeQueue` contract cleaner and more focused on its core queuing logic.
@LukeAVanDrie LukeAVanDrie force-pushed the feat/flow-control-managed-queue branch from fc2588b to b3be747 Compare July 17, 2025 21:28
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 17, 2025
@kfswain
Copy link
Collaborator

kfswain commented Jul 17, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 17, 2025
@k8s-ci-robot k8s-ci-robot merged commit 8e962f1 into kubernetes-sigs:main Jul 17, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants