Make scale event properties more conditional and serialized correctly

This commit is contained in:
Michael Lange
2020-07-27 21:29:22 -07:00
parent 9c5a2b5dd5
commit 9008694ab7
4 changed files with 27 additions and 8 deletions

View File

@@ -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 }));
})
);

View File

@@ -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'],
}
: {},
});

View File

@@ -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,

View File

@@ -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'), {});
}