mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 01:15:43 +03:00
Make scale event properties more conditional and serialized correctly
This commit is contained in:
@@ -161,7 +161,6 @@ export default function() {
|
||||
'/job/:id/scale',
|
||||
withBlockingSupport(function({ jobScales }, { params }) {
|
||||
const obj = jobScales.findBy({ jobId: params.id });
|
||||
console.log('Job Scale Object', obj);
|
||||
return this.serialize(jobScales.findBy({ jobId: params.id }));
|
||||
})
|
||||
);
|
||||
|
||||
@@ -7,11 +7,14 @@ export default Factory.extend({
|
||||
time: () => faker.date.past(2 / 365, REF_TIME) * 1000000,
|
||||
count: () => faker.random.number(10),
|
||||
previousCount: () => faker.random.number(10),
|
||||
error: () => faker.random.number(10) > 9,
|
||||
error: () => faker.random.number(10) > 8,
|
||||
message: 'Sample message for a job scale event',
|
||||
meta: () => ({
|
||||
'nomad_autoscaler.count.capped': true,
|
||||
'nomad_autoscaler.count.original': 0,
|
||||
'nomad_autoscaler.reason_history': ['scaling down because factor is 0.000000'],
|
||||
}),
|
||||
meta: () =>
|
||||
faker.random.number(10) < 8
|
||||
? {
|
||||
'nomad_autoscaler.count.capped': true,
|
||||
'nomad_autoscaler.count.original': 0,
|
||||
'nomad_autoscaler.reason_history': ['scaling down because factor is 0.000000'],
|
||||
}
|
||||
: {},
|
||||
});
|
||||
|
||||
@@ -2,7 +2,9 @@ import { Factory, trait } from 'ember-cli-mirage';
|
||||
import faker from 'nomad-ui/mirage/faker';
|
||||
|
||||
export default Factory.extend({
|
||||
name: id => id,
|
||||
name() {
|
||||
return this.id;
|
||||
},
|
||||
|
||||
desired: 1,
|
||||
placed: 1,
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
import ApplicationSerializer from './application';
|
||||
import { arrToObj } from '../utils';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
embed: true,
|
||||
include: ['taskGroupScales'],
|
||||
|
||||
serialize() {
|
||||
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
|
||||
if (json instanceof Array) {
|
||||
json.forEach(serializeJobScale);
|
||||
} else {
|
||||
serializeJobScale(json);
|
||||
}
|
||||
return json;
|
||||
},
|
||||
});
|
||||
|
||||
function serializeJobScale(jobScale) {
|
||||
jobScale.TaskGroups = jobScale.TaskGroupScales.reduce(arrToObj('Name'), {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user