Skip to content

Commit 407aa87

Browse files
committed
implement Name() for all plugins
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
1 parent a827e20 commit 407aa87

File tree

17 files changed

+138
-16
lines changed

17 files changed

+138
-16
lines changed

conformance/testing-epp/plugins/filter/request_header_based_filter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func (f *HeaderBasedTestingFilter) Type() string {
4949
return "header-based-testing"
5050
}
5151

52+
// Name returns the type of the filter.
53+
func (f *HeaderBasedTestingFilter) Name() string {
54+
return "header-based-testing-filter"
55+
}
56+
5257
// Filter selects pods that match the IP addresses specified in the request header.
5358
func (f *HeaderBasedTestingFilter) Filter(_ context.Context, request *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
5459
headerValue, ok := request.Headers[headerTestEppEndPointSelectionKey]

pkg/epp/common/config/configloader_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ func (f *test1) Type() string {
475475
return test1Type
476476
}
477477

478+
func (f *test1) Name() string {
479+
return "test-1"
480+
}
481+
478482
// Filter filters out pods that doesn't meet the filter criteria.
479483
func (f *test1) Filter(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) []types.Pod {
480484
return pods
@@ -490,6 +494,10 @@ func (f *test2) Type() string {
490494
return test2Type
491495
}
492496

497+
func (f *test2) Name() string {
498+
return "test-2"
499+
}
500+
493501
func (m *test2) Score(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) map[types.Pod]float64 {
494502
return map[types.Pod]float64{}
495503
}
@@ -506,6 +514,10 @@ func (p *testPicker) Type() string {
506514
return testPickerType
507515
}
508516

517+
func (p *testPicker) Name() string {
518+
return "test-picker"
519+
}
520+
509521
func (p *testPicker) Pick(ctx context.Context, cycleState *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult {
510522
return nil
511523
}
@@ -519,6 +531,10 @@ func (p *testProfileHandler) Type() string {
519531
return testProfileHandlerType
520532
}
521533

534+
func (p *testProfileHandler) Name() string {
535+
return "test-profile-handler"
536+
}
537+
522538
func (p *testProfileHandler) Pick(ctx context.Context, request *types.LLMRequest, profiles map[string]*framework.SchedulerProfile, executionResults map[string]*types.ProfileRunResult) map[string]*framework.SchedulerProfile {
523539
return nil
524540
}

pkg/epp/plugins/plugins.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ package plugins
2121
type Plugin interface {
2222
// Type returns the type of the plugin.
2323
Type() string
24+
// Name returns the name of the plugin.
25+
Name() string
2426
}
2527

26-
// Handle provides plugins set of standard data and tools to work with
28+
// Handle provides plugins a set of standard data and tools to work with
2729
type Handle interface {
2830
}

pkg/epp/requestcontrol/director_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ type testPostResponse struct {
565565
}
566566

567567
func (p *testPostResponse) Type() string { return p.TypeRes }
568+
func (p *testPostResponse) Name() string { return "test-post-response" }
568569

569570
func (p *testPostResponse) PostResponse(_ context.Context, _ *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {
570571
p.lastRespOnResponse = response

pkg/epp/scheduling/framework/plugins/filter/decision_tree_filter.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ func (f *DecisionTreeFilter) Type() string {
5555
return f.Current.Type()
5656
}
5757

58+
// Name returns the name of the filter.
59+
func (f *DecisionTreeFilter) Name() string {
60+
if f == nil {
61+
return ""
62+
}
63+
return f.Current.Name()
64+
}
65+
5866
// Filter filters out pods that doesn't meet the filter criteria.
5967
func (f *DecisionTreeFilter) Filter(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) []types.Pod {
6068
loggerTrace := log.FromContext(ctx).V(logutil.TRACE)

pkg/epp/scheduling/framework/plugins/filter/filter_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (f *filterAll) Type() string {
3939
return "filter-all"
4040
}
4141

42+
func (f *filterAll) Name() string {
43+
return "test-all"
44+
}
45+
4246
func (f *filterAll) Filter(_ context.Context, _ *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
4347
return []types.Pod{}
4448
}

pkg/epp/scheduling/framework/plugins/filter/least_kvcache_filter.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ var _ framework.Filter = &LeastKVCacheFilter{}
3535

3636
// LeastKVCacheFilterFactory defines the factory function for LeastKVCacheFilter.
3737
func LeastKVCacheFilterFactory(name string, _ json.RawMessage, _ plugins.Handle) (plugins.Plugin, error) {
38-
return NewLeastKVCacheFilter(), nil
38+
return &LeastKVCacheFilter{
39+
name: name,
40+
}, nil
3941
}
4042

4143
// NewLeastKVCacheFilter initializes a new LeastKVCacheFilter and returns its pointer.
@@ -48,13 +50,20 @@ func NewLeastKVCacheFilter() *LeastKVCacheFilter {
4850
// The intuition is that if there are multiple pods that share similar KV cache in the low range, we
4951
// should consider them all instead of the absolute minimum one. This worked better than picking the
5052
// least one as it gives more choices for the next filter, which on aggregate gave better results.
51-
type LeastKVCacheFilter struct{}
53+
type LeastKVCacheFilter struct {
54+
name string
55+
}
5256

5357
// Type returns the type of the filter.
5458
func (f *LeastKVCacheFilter) Type() string {
5559
return LeastKVCacheFilterType
5660
}
5761

62+
// Name returns the name of the filter.
63+
func (f *LeastKVCacheFilter) Name() string {
64+
return f.name
65+
}
66+
5867
// Filter filters out pods that doesn't meet the filter criteria.
5968
func (f *LeastKVCacheFilter) Filter(_ context.Context, _ *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
6069
filteredPods := []types.Pod{}

pkg/epp/scheduling/framework/plugins/filter/least_queue_filter.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ var _ framework.Filter = &LeastQueueFilter{}
3535

3636
// LeastQueueFilterFactory defines the factory function for LeastQueueFilter.
3737
func LeastQueueFilterFactory(name string, _ json.RawMessage, _ plugins.Handle) (plugins.Plugin, error) {
38-
return NewLeastQueueFilter(), nil
38+
return &LeastQueueFilter{
39+
name: name,
40+
}, nil
3941
}
4042

4143
// NewLeastQueueFilter initializes a new LeastQueueFilter and returns its pointer.
@@ -48,13 +50,20 @@ func NewLeastQueueFilter() *LeastQueueFilter {
4850
// The intuition is that if there are multiple pods that share similar queue size in the low range,
4951
// we should consider them all instead of the absolute minimum one. This worked better than picking
5052
// the least one as it gives more choices for the next filter, which on aggregate gave better results.
51-
type LeastQueueFilter struct{}
53+
type LeastQueueFilter struct {
54+
name string
55+
}
5256

5357
// Type returns the type of the filter.
5458
func (f *LeastQueueFilter) Type() string {
5559
return LeastQueueFilterType
5660
}
5761

62+
// Name returns the name of the filter.
63+
func (f *LeastQueueFilter) Name() string {
64+
return f.name
65+
}
66+
5867
// Filter filters out pods that doesn't meet the filter criteria.
5968
func (f *LeastQueueFilter) Filter(_ context.Context, _ *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
6069
filteredPods := []types.Pod{}

pkg/epp/scheduling/framework/plugins/filter/lora_affinity_filter.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func LoraAffinityFilterFactory(name string, rawParameters json.RawMessage, _ plu
4646
if err := json.Unmarshal(rawParameters, &parameters); err != nil {
4747
return nil, fmt.Errorf("failed to parse the parameters of the '%s' filter - %w", LoraAffinityFilterType, err)
4848
}
49-
return NewLoraAffinityFilter(parameters.Threshold), nil
49+
return &LoraAffinityFilter{
50+
name: name,
51+
loraAffinityThreshold: parameters.Threshold}, nil
5052
}
5153

5254
// NewLoraAffinityFilter initializes a new LoraAffinityFilter and returns its pointer.
@@ -64,6 +66,7 @@ func NewLoraAffinityFilter(threshold float64) *LoraAffinityFilter {
6466
// 2. Using a probability threshold to sometimes select from non-affinity pods to enable load balancing
6567
// 3. Falling back to whatever group has pods if one group is empty
6668
type LoraAffinityFilter struct {
69+
name string
6770
loraAffinityThreshold float64
6871
}
6972

@@ -72,6 +75,11 @@ func (f *LoraAffinityFilter) Type() string {
7275
return LoraAffinityFilterType
7376
}
7477

78+
// Name returns the type of the filter.
79+
func (f *LoraAffinityFilter) Name() string {
80+
return f.name
81+
}
82+
7583
// Filter filters out pods that doesn't meet the filter criteria.
7684
func (f *LoraAffinityFilter) Filter(_ context.Context, request *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
7785
// Pre-allocate slices with estimated capacity

pkg/epp/scheduling/framework/plugins/filter/low_queue_filter.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func LowQueueFilterFactory(name string, rawParameters json.RawMessage, _ plugins
4646
return nil, fmt.Errorf("failed to parse the parameters of the '%s' filter - %w", LowQueueFilterType, err)
4747
}
4848

49-
return NewLowQueueFilter(parameters.Threshold), nil
49+
return &LowQueueFilter{
50+
name: name,
51+
queueingThresholdLoRA: parameters.Threshold}, nil
5052
}
5153

5254
// NewLowQueueFilter initializes a new LowQueueFilter and returns its pointer.
@@ -58,6 +60,7 @@ func NewLowQueueFilter(threshold int) *LowQueueFilter {
5860

5961
// LowQueueFilter returns pods that their waiting queue size is less than a configured threshold
6062
type LowQueueFilter struct {
63+
name string
6164
queueingThresholdLoRA int
6265
}
6366

@@ -66,6 +69,11 @@ func (f *LowQueueFilter) Type() string {
6669
return LowQueueFilterType
6770
}
6871

72+
// Name returns the name of the filter.
73+
func (f *LowQueueFilter) Name() string {
74+
return f.name
75+
}
76+
6977
// Filter filters out pods that doesn't meet the filter criteria.
7078
func (f *LowQueueFilter) Filter(_ context.Context, _ *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
7179
filteredPods := []types.Pod{}

0 commit comments

Comments
 (0)