Skip to content

Commit 8048435

Browse files
committed
Add tests for resource fungibility plugin
1 parent 4ba4b0b commit 8048435

3 files changed

Lines changed: 391 additions & 40 deletions

File tree

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module github.com/inftyai/scheduler
33
go 1.24.1
44

55
require (
6+
github.com/google/go-cmp v0.7.0
67
github.com/inftyai/llmaz v0.1.3
8+
github.com/stretchr/testify v1.10.0
79
k8s.io/api v0.33.1
810
k8s.io/apimachinery v0.33.1
911
k8s.io/client-go v0.33.1
@@ -38,7 +40,6 @@ require (
3840
github.com/google/btree v1.1.3 // indirect
3941
github.com/google/cel-go v0.23.2 // indirect
4042
github.com/google/gnostic-models v0.6.9 // indirect
41-
github.com/google/go-cmp v0.7.0 // indirect
4243
github.com/google/uuid v1.6.0 // indirect
4344
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
4445
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
@@ -53,6 +54,7 @@ require (
5354
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5455
github.com/opencontainers/go-digest v1.0.0 // indirect
5556
github.com/pkg/errors v0.9.1 // indirect
57+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
5658
github.com/prometheus/client_golang v1.22.0 // indirect
5759
github.com/prometheus/client_model v0.6.1 // indirect
5860
github.com/prometheus/common v0.62.0 // indirect

pkg/plugins/resource_fungibility/resource_fungibility.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ var (
5353
resource = "openmodels"
5454
)
5555

56-
// TODO: get the inference service to extract the flavors.
5756
type ResourceFungibility struct {
5857
handle framework.Handle
59-
dynClient *dynamic.DynamicClient
58+
dynClient dynamic.Interface
6059
}
6160

6261
type flavor struct {
@@ -172,6 +171,11 @@ func (rf *ResourceFungibility) calPreFilterState(ctx context.Context, pod *v1.Po
172171
}
173172
}
174173

174+
if len(serviceFlavors) == 0 {
175+
s.shouldSkip = true
176+
return nil
177+
}
178+
175179
for _, f := range serviceFlavors {
176180
if len(f.NodeSelector) == 0 {
177181
// Once nodeSelector is empty, which means all nodes are potential candidates,

0 commit comments

Comments
 (0)