Skip to content

Commit

Permalink
Merge pull request #3956 from hashicorp/b-ui-placement-failures-persist
Browse files Browse the repository at this point in the history
Only show the placement failures section if there is a blocked eval
  • Loading branch information
DingoEatingFuzz committed Mar 9, 2018
2 parents 220790f + a1e34f0 commit bc4ae22
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ui/app/models/evaluation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bool } from '@ember/object/computed';
import { bool, equal } from '@ember/object/computed';
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo } from 'ember-data/relationships';
Expand All @@ -15,6 +15,7 @@ export default Model.extend({
failedTGAllocs: fragmentArray('placement-failure', { defaultValue: () => [] }),

hasPlacementFailures: bool('failedTGAllocs.length'),
isBlocked: equal('status', 'blocked'),

// TEMPORARY: https://github.com/emberjs/data/issues/5209
originalJobId: attr('string'),
Expand Down
10 changes: 8 additions & 2 deletions ui/app/models/job.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { alias, bool, equal, or } from '@ember/object/computed';
import { alias, equal, or, and } from '@ember/object/computed';
import { computed } from '@ember/object';
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
Expand Down Expand Up @@ -106,7 +106,13 @@ export default Model.extend({
evaluations: hasMany('evaluations'),
namespace: belongsTo('namespace'),

hasPlacementFailures: bool('latestFailureEvaluation'),
hasBlockedEvaluation: computed('evaluations.@each.isBlocked', function() {
return this.get('evaluations')
.toArray()
.some(evaluation => evaluation.get('isBlocked'));
}),

hasPlacementFailures: and('latestFailureEvaluation', 'hasBlockedEvaluation'),

latestEvaluation: computed('evaluations.@each.modifyIndex', 'evaluations.isPending', function() {
const evaluations = this.get('evaluations');
Expand Down
4 changes: 2 additions & 2 deletions ui/mirage/factories/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { provide, pickOne } from '../utils';
import { DATACENTERS } from '../common';

const EVAL_TYPES = ['system', 'service', 'batch'];
const EVAL_STATUSES = ['blocked', 'pending', 'complete', 'failed', 'canceled'];
const EVAL_STATUSES = ['pending', 'complete', 'failed', 'canceled'];
const EVAL_TRIGGERED_BY = [
'job-register',
'job-deregister',
Expand Down Expand Up @@ -55,7 +55,7 @@ export default Factory.extend({
modifyIndex: () => faker.random.number({ min: 10, max: 2000 }),

withPlacementFailures: trait({
status: faker.list.random(...EVAL_STATUSES.without('blocked')),
status: 'blocked',
afterCreate(evaluation, server) {
assignJob(evaluation, server);
const taskGroups = server.db.taskGroups.where({ jobId: evaluation.jobId });
Expand Down

0 comments on commit bc4ae22

Please sign in to comment.