Skip to content
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

feat(advisor): support disable registered model result fetcher #321

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/agent/sysadvisor/plugin/inference/inference.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func NewInferencePlugin(pluginName string, conf *config.Configuration, extraConf
fetcher, err := initFn(fetcherName, conf, extraConf, emitterPool, metaServer, metaCache)
if err != nil {
return nil, fmt.Errorf("failed to start sysadvisor plugin %v: %v", pluginName, err)
} else if fetcher == nil {
general.Infof("fetcher: %s isn't enabled", fetcherName)
continue
}

inferencePlugin.modelsResultFetchers[fetcherName] = fetcher
Expand Down
8 changes: 8 additions & 0 deletions pkg/agent/sysadvisor/plugin/inference/inference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import (
metricspool "github.com/kubewharf/katalyst-core/pkg/metrics/metrics-pool"
)

func NewNilModelResultFetcher(fetcherName string, conf *config.Configuration, extraConf interface{},
emitterPool metricspool.MetricsEmitterPool, metaServer *metaserver.MetaServer,
metaCache metacache.MetaCache) (modelresultfetcher.ModelResultFetcher, error) {
return nil, nil
}

func TestNewInferencePlugin(t *testing.T) {
t.Parallel()
type args struct {
Expand Down Expand Up @@ -63,6 +69,8 @@ func TestNewInferencePlugin(t *testing.T) {

modelresultfetcher.RegisterModelResultFetcherInitFunc(borweinfetcher.BorweinModelResultFetcherName,
modelresultfetcher.NewDummyModelResultFetcher)
modelresultfetcher.RegisterModelResultFetcherInitFunc("test-nil-fetcher",
NewNilModelResultFetcher)

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ func NewBorweinModelResultFetcher(fetcherName string, conf *config.Configuration
metaCache metacache.MetaCache) (modelresultfetcher.ModelResultFetcher, error) {
if conf == nil || conf.BorweinConfiguration == nil {
return nil, fmt.Errorf("nil conf")
} else if !conf.PolicyRama.EnableBorwein {
return nil, nil
} else if metaServer == nil {
return nil, fmt.Errorf("nil metaServer")
} else if metaCache == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ func TestNewBorweinModelResultFetcher(t *testing.T) {

type args struct {
fetcherName string
enableBorwein bool
conf *config.Configuration
extraConf interface{}
emitterPool metricspool.MetricsEmitterPool
Expand All @@ -700,6 +701,7 @@ func TestNewBorweinModelResultFetcher(t *testing.T) {
name: "test normal new borwein model result fetcher",
args: args{
fetcherName: BorweinModelResultFetcherName,
enableBorwein: true,
conf: conf,
emitterPool: metricspool.DummyMetricsEmitterPool{},
metaServer: metaServer,
Expand All @@ -711,18 +713,20 @@ func TestNewBorweinModelResultFetcher(t *testing.T) {
{
name: "test new borwein with nil conf",
args: args{
fetcherName: BorweinModelResultFetcherName,
conf: nil,
emitterPool: metricspool.DummyMetricsEmitterPool{},
metaServer: metaServer,
metaCache: mc,
fetcherName: BorweinModelResultFetcherName,
enableBorwein: true,
conf: nil,
emitterPool: metricspool.DummyMetricsEmitterPool{},
metaServer: metaServer,
metaCache: mc,
},
wantErr: true,
},
{
name: "test new borwein with nil metaServer",
args: args{
fetcherName: BorweinModelResultFetcherName,
enableBorwein: true,
conf: conf,
emitterPool: metricspool.DummyMetricsEmitterPool{},
metaServer: nil,
Expand All @@ -735,6 +739,7 @@ func TestNewBorweinModelResultFetcher(t *testing.T) {
name: "test new borwein with nil metacache",
args: args{
fetcherName: BorweinModelResultFetcherName,
enableBorwein: true,
conf: conf,
emitterPool: metricspool.DummyMetricsEmitterPool{},
metaServer: metaServer,
Expand All @@ -743,9 +748,25 @@ func TestNewBorweinModelResultFetcher(t *testing.T) {
},
wantErr: true,
},
{
name: "test new borwein fetcher with enableBorwein false",
args: args{
fetcherName: BorweinModelResultFetcherName,
enableBorwein: false,
conf: conf,
emitterPool: metricspool.DummyMetricsEmitterPool{},
metaServer: metaServer,
metaCache: nil,
inferenceServiceSocketAbsPath: path.Join(sockDir, "test.sock"),
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.args.conf != nil {
tt.args.conf.PolicyRama.EnableBorwein = tt.args.enableBorwein
}

var svr *grpc.Server
if tt.args.inferenceServiceSocketAbsPath != "" {
Expand All @@ -754,9 +775,18 @@ func TestNewBorweinModelResultFetcher(t *testing.T) {
conf.BorweinConfiguration.InferenceServiceSocketAbsPath = tt.args.inferenceServiceSocketAbsPath
}

_, err := NewBorweinModelResultFetcher(tt.args.fetcherName, tt.args.conf, tt.args.extraConf, tt.args.emitterPool, tt.args.metaServer, tt.args.metaCache)
fetcher, err := NewBorweinModelResultFetcher(tt.args.fetcherName, tt.args.conf, tt.args.extraConf, tt.args.emitterPool, tt.args.metaServer, tt.args.metaCache)
if (err != nil) != tt.wantErr {
t.Errorf("NewBorweinModelResultFetcher() error = %v, wantErr %v", err, tt.wantErr)
if svr != nil {
svr.Stop()
}
return
} else if !tt.args.enableBorwein {
require.Nil(t, fetcher)
if svr != nil {
svr.Stop()
}
return
}

Expand Down