From 9d86a5277d1972ee50c46e51144e962dbd4625b3 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Sun, 2 May 2021 22:53:53 -0400 Subject: [PATCH] api: actually set MemoryOversubscriptionEnabled (#10493) --- api/operator.go | 3 +++ command/agent/operator_endpoint.go | 3 ++- command/agent/operator_endpoint_test.go | 14 ++++++++++---- vendor/github.com/hashicorp/nomad/api/operator.go | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/api/operator.go b/api/operator.go index e05b9103f..6a6db4917 100644 --- a/api/operator.go +++ b/api/operator.go @@ -126,6 +126,9 @@ type SchedulerConfiguration struct { // priority jobs to place higher priority jobs. PreemptionConfig PreemptionConfig + // MemoryOversubscriptionEnabled specifies whether memory oversubscription is enabled + MemoryOversubscriptionEnabled bool + // CreateIndex/ModifyIndex store the create/modify indexes of this configuration. CreateIndex uint64 ModifyIndex uint64 diff --git a/command/agent/operator_endpoint.go b/command/agent/operator_endpoint.go index ed4a3c4cb..e6713a45d 100644 --- a/command/agent/operator_endpoint.go +++ b/command/agent/operator_endpoint.go @@ -259,7 +259,8 @@ func (s *HTTPServer) schedulerUpdateConfig(resp http.ResponseWriter, req *http.R } args.Config = structs.SchedulerConfiguration{ - SchedulerAlgorithm: structs.SchedulerAlgorithm(conf.SchedulerAlgorithm), + SchedulerAlgorithm: structs.SchedulerAlgorithm(conf.SchedulerAlgorithm), + MemoryOversubscriptionEnabled: conf.MemoryOversubscriptionEnabled, PreemptionConfig: structs.PreemptionConfig{ SystemSchedulerEnabled: conf.PreemptionConfig.SystemSchedulerEnabled, BatchSchedulerEnabled: conf.PreemptionConfig.BatchSchedulerEnabled, diff --git a/command/agent/operator_endpoint_test.go b/command/agent/operator_endpoint_test.go index 8814fad4f..318e34e8b 100644 --- a/command/agent/operator_endpoint_test.go +++ b/command/agent/operator_endpoint_test.go @@ -284,6 +284,7 @@ func TestOperator_SchedulerGetConfiguration(t *testing.T) { require.True(out.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled) require.False(out.SchedulerConfig.PreemptionConfig.BatchSchedulerEnabled) require.False(out.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled) + require.False(out.SchedulerConfig.MemoryOversubscriptionEnabled) }) } @@ -291,10 +292,14 @@ func TestOperator_SchedulerSetConfiguration(t *testing.T) { t.Parallel() httpTest(t, nil, func(s *TestAgent) { require := require.New(t) - body := bytes.NewBuffer([]byte(`{"PreemptionConfig": { - "SystemSchedulerEnabled": true, - "ServiceSchedulerEnabled": true - }}`)) + body := bytes.NewBuffer([]byte(` +{ + "MemoryOversubscriptionEnabled": true, + "PreemptionConfig": { + "SystemSchedulerEnabled": true, + "ServiceSchedulerEnabled": true + } +}`)) req, _ := http.NewRequest("PUT", "/v1/operator/scheduler/configuration", body) resp := httptest.NewRecorder() setResp, err := s.Server.OperatorSchedulerConfiguration(resp, req) @@ -315,6 +320,7 @@ func TestOperator_SchedulerSetConfiguration(t *testing.T) { require.Nil(err) require.True(reply.SchedulerConfig.PreemptionConfig.SystemSchedulerEnabled) require.True(reply.SchedulerConfig.PreemptionConfig.ServiceSchedulerEnabled) + require.True(reply.SchedulerConfig.MemoryOversubscriptionEnabled) }) } diff --git a/vendor/github.com/hashicorp/nomad/api/operator.go b/vendor/github.com/hashicorp/nomad/api/operator.go index e05b9103f..6a6db4917 100644 --- a/vendor/github.com/hashicorp/nomad/api/operator.go +++ b/vendor/github.com/hashicorp/nomad/api/operator.go @@ -126,6 +126,9 @@ type SchedulerConfiguration struct { // priority jobs to place higher priority jobs. PreemptionConfig PreemptionConfig + // MemoryOversubscriptionEnabled specifies whether memory oversubscription is enabled + MemoryOversubscriptionEnabled bool + // CreateIndex/ModifyIndex store the create/modify indexes of this configuration. CreateIndex uint64 ModifyIndex uint64