Skip to content

feat(standalone): use typed labels.Selector for endpoint selector#1701

Merged
ahg-g merged 1 commit into
llm-d:mainfrom
shichaooutlook:feat/typed-endpoint-selector
Jun 27, 2026
Merged

feat(standalone): use typed labels.Selector for endpoint selector#1701
ahg-g merged 1 commit into
llm-d:mainfrom
shichaooutlook:feat/typed-endpoint-selector

Conversation

@shichaooutlook

Copy link
Copy Markdown
Contributor

Replace the string-based --endpoint-selector flag with Kubernetes-native labels.Selector to support set-based label expressions (e.g., env in (prod,staging),tier!=frontend, key,!deprecated) in
standalone mode.
Motivation

 The current --endpoint-selector only supports simple key=value pairs via labels.ConvertSelectorToLabelsMap. This is too restrictive — operators running llm-d outside Kubernetes may need set-based
 selectors to match pods by environment, tier, or exclusion patterns. The upstream code already had a TODO comment: // TODO: k8s.Selector, pflag.StringSlice? — this PR implements that TODO.
 Changes

 - Options.EndpointSelector: type changed from string to labels.Selector
 - Options.Complete(): parses the flag string via labels.Parse() and stores the result
 - EndpointPool.Selector: type changed from map[string]string to labels.Selector
 - Datastore.PoolLabelsMatch: simplified — uses native Selector.Matches() inline instead of constructing a temporary selector
 - Datastore.podResyncAll: passes labels.Selector directly to K8s List API
 - Datastore.selectorEqual: new nil-safe helper for labels.Selector comparison
 - InferencePoolToEndpointPool: uses labels.SelectorFromSet() instead of raw map
 - All callers and tests updated for the new type
 - CLI flag help text updated to document set-based syntax
 Test Plan

 - [x] go test ./pkg/epp/datastore/... — PASS
 - [x] go test ./pkg/epp/controller/... — PASS
 - [x] go test ./pkg/epp/server/... — PASS
 Notes for Reviewers

 - EndpointSelector is now nil (typed nil) when not set, replacing the previous empty string ""
 - All checks now use == nil / != nil instead of == "" / != ""
 - labels.Selector is an interface, not comparable with == — selectorEqual helper and cmp.Comparer handle this
 - Backward compatible at the CLI level: all previously valid key=value selectors remain valid

@shichaooutlook
shichaooutlook requested a review from a team as a code owner June 22, 2026 06:14
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

@github-actions github-actions Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 22, 2026
@shichaooutlook
shichaooutlook force-pushed the feat/typed-endpoint-selector branch 5 times, most recently from e4d280d to f3b8068 Compare June 22, 2026 07:42
Replace the string-based --endpoint-selector flag with
Kubernetes-native labels.Selector to support set-based
label expressions (e.g., 'env in (prod,staging),tier!=frontend',
'key,!deprecated') in standalone mode.

- EndpointSelector type: string -> labels.Selector
- Complete(): parse flag string via labels.Parse()
- EndpointPool.Selector: map[string]string -> labels.Selector
- PoolLabelsMatch simplified with native Selector.Matches()
- podResyncAll passes Selector directly to K8s client
- All callers and tests updated for new type

Signed-off-by: shichaooutlook <shichao.outlook@gmail.com>
@shichaooutlook
shichaooutlook force-pushed the feat/typed-endpoint-selector branch from f3b8068 to 64b4b76 Compare June 23, 2026 01:06
@ahg-g
ahg-g enabled auto-merge (squash) June 27, 2026 10:35
@ahg-g
ahg-g merged commit bcbca9a into llm-d:main Jun 27, 2026
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants