Update drain methods to properly wrap DrainSpec params

This commit is contained in:
Michael Lange
2019-10-30 11:24:09 -07:00
parent 4ddcd6044e
commit 0b031f0b27
2 changed files with 36 additions and 16 deletions

View File

@@ -25,14 +25,16 @@ export default Watchable.extend({
drain(node, drainSpec) {
const url = addToPath(this.urlForFindRecord(node.id, 'node'), '/drain');
return this.ajax(url, 'POST', {
data: Object.assign(
{
NodeID: node.id,
Deadline: 0,
IgnoreSystemJobs: true,
},
drainSpec
),
data: {
NodeID: node.id,
DrainSpec: Object.assign(
{
Deadline: 0,
IgnoreSystemJobs: true,
},
drainSpec
),
},
});
},
@@ -44,4 +46,14 @@ export default Watchable.extend({
})
);
},
cancelDrain(node) {
const url = addToPath(this.urlForFindRecord(node.id, 'node'), '/drain');
return this.ajax(url, 'POST', {
data: {
NodeID: node.id,
DrainSpec: null,
},
});
},
});

View File

@@ -145,8 +145,10 @@ module('Unit | Adapter | Node', function(hooks) {
JSON.parse(request.requestBody),
{
NodeID: node.id,
Deadline: 0,
IgnoreSystemJobs: true,
DrainSpec: {
Deadline: 0,
IgnoreSystemJobs: true,
},
},
'POST request is made with the default body arguments'
);
@@ -164,8 +166,10 @@ module('Unit | Adapter | Node', function(hooks) {
JSON.parse(request.requestBody),
{
NodeID: node.id,
Deadline: spec.Deadline,
IgnoreSystemJobs: spec.IgnoreSystemJobs,
DrainSpec: {
Deadline: spec.Deadline,
IgnoreSystemJobs: spec.IgnoreSystemJobs,
},
},
'POST request is made with the drain spec as body arguments'
);
@@ -184,8 +188,10 @@ module('Unit | Adapter | Node', function(hooks) {
JSON.parse(request.requestBody),
{
NodeID: node.id,
Deadline: -1000000000,
IgnoreSystemJobs: true,
DrainSpec: {
Deadline: -1000000000,
IgnoreSystemJobs: true,
},
},
'POST request is made with the default body arguments'
);
@@ -205,8 +211,10 @@ module('Unit | Adapter | Node', function(hooks) {
JSON.parse(request.requestBody),
{
NodeID: node.id,
Deadline: -1000000000,
IgnoreSystemJobs: spec.IgnoreSystemJobs,
DrainSpec: {
Deadline: -1000000000,
IgnoreSystemJobs: spec.IgnoreSystemJobs,
},
},
'POST request is made with the drain spec, except deadline is not overridden'
);