Skip to content
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: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "nova FilterWeigherPipelineController")
os.Exit(1)
}
nova.NewAPI(filterWeigherController).Init(mux)
novaAPIConfig := conf.GetConfigOrDie[nova.HTTPAPIConfig]()
nova.NewAPI(novaAPIConfig, filterWeigherController).Init(mux)

// Initialize commitments API for LIQUID interface
commitmentsAPI := commitments.NewAPI(multiclusterClient)
Expand Down
3 changes: 3 additions & 0 deletions helm/bundles/cortex-nova/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ cortex-scheduling-controllers:
- failover-reservations-controller
enabledTasks:
- nova-history-cleanup-task
# If true, the external scheduler API will limit the list of hosts in its
# response to those included in the scheduling request.
novaLimitHostsToRequest: true
# CommittedResourceFlavorGroupPipelines maps flavor group IDs to pipeline names for CR reservations
# This allows different scheduling strategies per flavor group (e.g., HANA vs GP)
committedResourceFlavorGroupPipelines:
Expand Down
16 changes: 14 additions & 2 deletions internal/scheduling/nova/external_scheduler_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@ type HTTPAPI interface {
Init(*http.ServeMux)
}

type HTTPAPIConfig struct {
// NovaLimitHostsToRequest, if true, will filter the Nova scheduler response
// to only include hosts that were in the original request.
NovaLimitHostsToRequest bool `json:"novaLimitHostsToRequest,omitempty"`
}

type httpAPI struct {
monitor scheduling.APIMonitor
delegate HTTPAPIDelegate
config HTTPAPIConfig
}

func NewAPI(delegate HTTPAPIDelegate) HTTPAPI {
func NewAPI(config HTTPAPIConfig, delegate HTTPAPIDelegate) HTTPAPI {
return &httpAPI{
monitor: scheduling.NewSchedulerMonitor(),
delegate: delegate,
config: config,
}
}

Expand Down Expand Up @@ -222,7 +230,11 @@ func (httpAPI *httpAPI) NovaExternalScheduler(w http.ResponseWriter, r *http.Req
return
}
hosts := decision.Status.Result.OrderedHosts
hosts = limitHostsToRequest(requestData, hosts)
if httpAPI.config.NovaLimitHostsToRequest {
hosts = limitHostsToRequest(requestData, hosts)
slog.Info("limited hosts to request",
"hosts", hosts, "originalHosts", decision.Status.Result.OrderedHosts)
}
response := api.ExternalSchedulerResponse{Hosts: hosts}
w.Header().Set("Content-Type", "application/json")
if err = json.NewEncoder(w).Encode(response); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/scheduling/nova/external_scheduler_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m *mockHTTPAPIDelegate) ProcessNewDecisionFromAPI(ctx context.Context, dec
func TestNewAPI(t *testing.T) {
delegate := &mockHTTPAPIDelegate{}

api := NewAPI(delegate)
api := NewAPI(HTTPAPIConfig{}, delegate)

if api == nil {
t.Fatal("NewAPI returned nil")
Expand All @@ -55,7 +55,7 @@ func TestNewAPI(t *testing.T) {

func TestHTTPAPI_Init(t *testing.T) {
delegate := &mockHTTPAPIDelegate{}
api := NewAPI(delegate)
api := NewAPI(HTTPAPIConfig{}, delegate)

mux := http.NewServeMux()
api.Init(mux)
Expand All @@ -73,7 +73,7 @@ func TestHTTPAPI_Init(t *testing.T) {

func TestHTTPAPI_canRunScheduler(t *testing.T) {
delegate := &mockHTTPAPIDelegate{}
api := NewAPI(delegate).(*httpAPI)
api := NewAPI(HTTPAPIConfig{}, delegate).(*httpAPI)

tests := []struct {
name string
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestHTTPAPI_NovaExternalScheduler(t *testing.T) {
},
}

api := NewAPI(delegate).(*httpAPI)
api := NewAPI(HTTPAPIConfig{}, delegate).(*httpAPI)

var body *strings.Reader
if tt.body != "" {
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestHTTPAPI_NovaExternalScheduler_DecisionCreation(t *testing.T) {
},
}

api := NewAPI(delegate).(*httpAPI)
api := NewAPI(HTTPAPIConfig{}, delegate).(*httpAPI)

requestData := novaapi.ExternalSchedulerRequest{
Spec: novaapi.NovaObject[novaapi.NovaSpec]{
Expand Down Expand Up @@ -508,7 +508,7 @@ func TestLimitHostsToRequest(t *testing.T) {

func TestHTTPAPI_inferPipelineName(t *testing.T) {
delegate := &mockHTTPAPIDelegate{}
api := NewAPI(delegate).(*httpAPI)
api := NewAPI(HTTPAPIConfig{}, delegate).(*httpAPI)

tests := []struct {
name string
Expand Down
Loading