Skip to content

feat: usage limit policy plugin#2530

Merged
k8s-ci-robot merged 10 commits into
kubernetes-sigs:mainfrom
evacchi:proposal-usage-limit-policy-2
Apr 2, 2026
Merged

feat: usage limit policy plugin#2530
k8s-ci-robot merged 10 commits into
kubernetes-sigs:mainfrom
evacchi:proposal-usage-limit-policy-2

Conversation

@evacchi

@evacchi evacchi commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR introduces pluggable UsageLimitPolicy interface. The goal is to complement "Improved Flow Control Request Management". The PR is a follow up to the initial discussion in #2268

The interfaces may be used to implement the proposal in the doc, as well as dynamically-adaptable behavior (as demonstrated here).

a UsageLimitPolicy returns a list of "ceilings" for a given list of priorities:

	// ComputeLimit calculates usage ceilings for all currently active priority levels based on current
	// saturation. The plugin observes the active priority domain (which changes dynamically as workloads
	// come and go) and computes relative ceilings from scratch on each call.
	//
	// Parameters:
	//   - ctx: Request context for logging, tracing, etc.
	//   - saturation: Current pool-wide resource saturation as a fraction [0.0, 1.0]
	//   - priorities: Ordered list of currently active priority levels (highest first)
	//
	// Returns:
	//   - ceilings: Computed ceiling for each given priority (n-th ceiling is assigned to the given n-th priority)
	//     - 0.0 = fully gated (cannot dispatch regardless of current saturation)
	//     - 1.0 = no gating (can dispatch until fully saturated)
	//     - Values between 0.0 and 1.0 reserve capacity headroom
	//
	ComputeLimit(ctx context.Context, saturation float64, priorities []int) (ceilings []float64)

We provide a few example/utility implementations:

  • a usagelimits.DefaultPolicy() that always returns 1.0 for all given priorities
  • a usagelimits.NewConstPolicy(usageLimitName string, threshold float64) constructor for fixed thresholds for all given priorities
  • a usagelimits.NewPolicyFunc(...) constructor to define a policy by a func
  • an example of registering and accessing a custom policy via config
  • an example of a linear spacing policy as described in feat: pool-wide saturation, usage limit policy and evictor #2268 (comment)

Note

This PR implicitly requires pool-wide saturation addressed in #2343; thus, this PR should ideally be merged after #2343, and it's likely to require a rebase then.

Which issue(s) this PR fixes:

Related #1861, #2268, #2343, Improved Flow Control Request Management

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 9, 2026
@netlify

netlify Bot commented Mar 9, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit abf251f
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/69cea1c108b5f90008900eef
😎 Deploy Preview https://deploy-preview-2530--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 requested review from kfswain and shmuelk March 9, 2026 14:04
@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 Mar 9, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @evacchi. 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

Details

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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 9, 2026
Comment thread pkg/epp/flowcontrol/controller/internal/processor.go
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2026
@evacchi
evacchi force-pushed the proposal-usage-limit-policy-2 branch from c0addfa to 5f1a9fc Compare March 11, 2026 07:58
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2026
Comment thread pkg/epp/flowcontrol/controller/internal/processor.go

@LukeAVanDrie LukeAVanDrie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new interface and its integration LGTM. Thanks for picking this up! I just have some feedback on the config loading path so we are consistent with other plugins.

registry contracts.FlowRegistry,
sd contracts.SaturationDetector,
podLocator contracts.PodLocator,
usageLimitPolicy flowcontrol.UsageLimitPolicy,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We may be getting to a point where we want to group dependencies into a config struct. Not blocking this PR on this refactoring effort though.

E.g.,

type Dependencies struct {
    Registry           contracts.FlowRegistry
    SaturationDetector contracts.SaturationDetector
    PodLocator         contracts.PodLocator
    UsageLimitPolicy   flowcontrol.UsageLimitPolicy
    Clock              clock.WithTicker
}
...
func NewFlowController(ctx context.Context, poolName string, config *Config, deps Dependencies) { ... }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good point, been thinking the same. Let's schedule this and the other refactoring. I can take this one if you'd like

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an issue tracking all followups?

@evacchi evacchi Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created issue for this #2764 will self-assign (the other one, i.e. unwrap the config value, I am doing in this PR)

Comment thread pkg/epp/flowcontrol/controller/internal/processor.go Outdated
Comment thread pkg/epp/framework/interface/flowcontrol/plugins.go Outdated
Comment thread cmd/epp/runner/runner.go Outdated
@evacchi

evacchi commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

thanks for suggestions, will address this tomorrow!

@evacchi
evacchi force-pushed the proposal-usage-limit-policy-2 branch 2 times, most recently from 1d91727 to 0b60d58 Compare March 12, 2026 11:39
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2026
@evacchi
evacchi force-pushed the proposal-usage-limit-policy-2 branch from d29a574 to 8690c86 Compare March 16, 2026 08:32
@evacchi
evacchi requested a review from LukeAVanDrie March 16, 2026 08:32
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 16, 2026
@evacchi

evacchi commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

rebasing

@evacchi
evacchi force-pushed the proposal-usage-limit-policy-2 branch from 8690c86 to fb7e8da Compare March 23, 2026 10:09
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 23, 2026
@evacchi

evacchi commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

double-checked integration into llm-d-inference-scheduler with a plugin impl there, and it should be fine

@evacchi
evacchi force-pushed the proposal-usage-limit-policy-2 branch from c81252e to 18e6590 Compare March 26, 2026 14:37
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
@LukeAVanDrie

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@ahg-g; mind taking a look at this when you get a moment?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 1, 2026
@ahg-g

ahg-g commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

/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 Apr 1, 2026
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 1, 2026
@evacchi

evacchi commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

@ahg-g good to go now

Comment thread apix/config/v1alpha1/endpointpickerconfig_types.go Outdated
registry contracts.FlowRegistry,
sd contracts.SaturationDetector,
podLocator contracts.PodLocator,
usageLimitPolicy flowcontrol.UsageLimitPolicy,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an issue tracking all followups?

Comment thread pkg/epp/flowcontrol/config.go
Comment thread pkg/epp/flowcontrol/controller/internal/processor.go Outdated
evacchi added 3 commits April 2, 2026 17:21
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
evacchi added 2 commits April 2, 2026 17:49
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Comment thread apix/config/v1alpha1/endpointpickerconfig_types.go Outdated
Comment thread pkg/epp/flowcontrol/registry/config.go Outdated
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
@ahg-g

ahg-g commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 2, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, evacchi, LukeAVanDrie

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

The pull request process is described here

Details 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2026
@k8s-ci-robot
k8s-ci-robot merged commit 0786ad0 into kubernetes-sigs:main Apr 2, 2026
11 checks passed
@evacchi
evacchi deleted the proposal-usage-limit-policy-2 branch April 2, 2026 18:57
elevran pushed a commit to llm-d/llm-d-router that referenced this pull request Apr 23, 2026
…e-extension#2530)

* feat: usage limit policy plugin

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* formatting

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* remove leftover runner_test.go

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* missing boilerplate header

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* replace Noop policy with StaticUsageLimitPolicy

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* hoist check to the top of dispatchCycle()

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* drop UsageLimitConfig wrapper

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* formatting

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* linting

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

* apply suggestions

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>

---------

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
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. kind/feature Categorizes issue or PR as related to a new feature. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants