open-nomad/ui/app/routes/allocations/allocation.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.3 KiB
JavaScript
Raw Normal View History

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { collect } from '@ember/object/computed';
import {
watchRecord,
watchNonStoreRecords,
} from 'nomad-ui/utils/properties/watch';
import WithWatchers from 'nomad-ui/mixins/with-watchers';
import notifyError from 'nomad-ui/utils/notify-error';
export default class AllocationRoute extends Route.extend(WithWatchers) {
@service notifications;
@service router;
@service store;
startWatchers(controller, model) {
2018-11-06 00:33:33 +00:00
if (model) {
2019-03-26 07:46:44 +00:00
controller.set('watcher', this.watch.perform(model));
Job Services: fixtures and acceptance tests (#14319) * Added to subnav and basic table implemented * Existing services become service fragments, and services tab aggregated beneath job route * Index page within jobs/job/services * Watchable services * Lintfixes * Links to clients and individual services set up * Child service route * Keyboard shortcuts on service page * Model that shows consul services as well, plus level and provider cols * lintfix * Level as query param * Watch job for service name changes too * Group level service fixtures established * Progress at task level and job-linked services * Task and group services on update * Fixture side-effect cleanup * Basic acceptance tests for job services * Testmodel cleanup * Disabled mirage logging * New cluster type specifically for services * Without explicit job-model binding * Trying to isolate a tostring error * Account for new tab in keyboardnav * More test isolation attempts * Remove skipped tests and link task to parent group by id ui: add service health viz to table (#14369) * ui: add service-status-bar * test: service-status-bar * refact: update component api for new data struct * ui: format service health struct * ui: add service health viz to table * temp: add placeholder to remind conditional watcher * test: write tests for transformation algorithm * refact: update transformation algo * ui: conditionally long poll checks endpoint * refact: add conditional logic for nomad provider refact: update service-fragment model to include owner info ui: differentiate between task and group-level in derived state comp test: add test to document behavior refact: update tests for api change refact: update integration test for API change chore: remove unsused vars chore: elvis operator to protect mirage refact: create refId instead of internalModel refact: update algo refact: update conditional template logic refact: update test for api change: chore: cant use if and not in hbs conditional
2022-08-29 18:04:55 +00:00
const anyGroupServicesAreNomad = !!model.taskGroup?.services?.filterBy(
'provider',
'nomad'
).length;
const anyTaskServicesAreNomad = model.states
.mapBy('task.services')
.compact()
.map((fragmentClass) => fragmentClass.mapBy('provider'))
.flat()
.any((provider) => provider === 'nomad');
Job Services: fixtures and acceptance tests (#14319) * Added to subnav and basic table implemented * Existing services become service fragments, and services tab aggregated beneath job route * Index page within jobs/job/services * Watchable services * Lintfixes * Links to clients and individual services set up * Child service route * Keyboard shortcuts on service page * Model that shows consul services as well, plus level and provider cols * lintfix * Level as query param * Watch job for service name changes too * Group level service fixtures established * Progress at task level and job-linked services * Task and group services on update * Fixture side-effect cleanup * Basic acceptance tests for job services * Testmodel cleanup * Disabled mirage logging * New cluster type specifically for services * Without explicit job-model binding * Trying to isolate a tostring error * Account for new tab in keyboardnav * More test isolation attempts * Remove skipped tests and link task to parent group by id ui: add service health viz to table (#14369) * ui: add service-status-bar * test: service-status-bar * refact: update component api for new data struct * ui: format service health struct * ui: add service health viz to table * temp: add placeholder to remind conditional watcher * test: write tests for transformation algorithm * refact: update transformation algo * ui: conditionally long poll checks endpoint * refact: add conditional logic for nomad provider refact: update service-fragment model to include owner info ui: differentiate between task and group-level in derived state comp test: add test to document behavior refact: update tests for api change refact: update integration test for API change chore: remove unsused vars chore: elvis operator to protect mirage refact: create refId instead of internalModel refact: update algo refact: update conditional template logic refact: update test for api change: chore: cant use if and not in hbs conditional
2022-08-29 18:04:55 +00:00
// Conditionally Long Poll /checks endpoint if alloc has nomad services
if (anyGroupServicesAreNomad || anyTaskServicesAreNomad) {
Job Services: fixtures and acceptance tests (#14319) * Added to subnav and basic table implemented * Existing services become service fragments, and services tab aggregated beneath job route * Index page within jobs/job/services * Watchable services * Lintfixes * Links to clients and individual services set up * Child service route * Keyboard shortcuts on service page * Model that shows consul services as well, plus level and provider cols * lintfix * Level as query param * Watch job for service name changes too * Group level service fixtures established * Progress at task level and job-linked services * Task and group services on update * Fixture side-effect cleanup * Basic acceptance tests for job services * Testmodel cleanup * Disabled mirage logging * New cluster type specifically for services * Without explicit job-model binding * Trying to isolate a tostring error * Account for new tab in keyboardnav * More test isolation attempts * Remove skipped tests and link task to parent group by id ui: add service health viz to table (#14369) * ui: add service-status-bar * test: service-status-bar * refact: update component api for new data struct * ui: format service health struct * ui: add service health viz to table * temp: add placeholder to remind conditional watcher * test: write tests for transformation algorithm * refact: update transformation algo * ui: conditionally long poll checks endpoint * refact: add conditional logic for nomad provider refact: update service-fragment model to include owner info ui: differentiate between task and group-level in derived state comp test: add test to document behavior refact: update tests for api change refact: update integration test for API change chore: remove unsused vars chore: elvis operator to protect mirage refact: create refId instead of internalModel refact: update algo refact: update conditional template logic refact: update test for api change: chore: cant use if and not in hbs conditional
2022-08-29 18:04:55 +00:00
controller.set(
'watchHealthChecks',
this.watchHealthChecks.perform(model, 'getServiceHealth', 2000)
Job Services: fixtures and acceptance tests (#14319) * Added to subnav and basic table implemented * Existing services become service fragments, and services tab aggregated beneath job route * Index page within jobs/job/services * Watchable services * Lintfixes * Links to clients and individual services set up * Child service route * Keyboard shortcuts on service page * Model that shows consul services as well, plus level and provider cols * lintfix * Level as query param * Watch job for service name changes too * Group level service fixtures established * Progress at task level and job-linked services * Task and group services on update * Fixture side-effect cleanup * Basic acceptance tests for job services * Testmodel cleanup * Disabled mirage logging * New cluster type specifically for services * Without explicit job-model binding * Trying to isolate a tostring error * Account for new tab in keyboardnav * More test isolation attempts * Remove skipped tests and link task to parent group by id ui: add service health viz to table (#14369) * ui: add service-status-bar * test: service-status-bar * refact: update component api for new data struct * ui: format service health struct * ui: add service health viz to table * temp: add placeholder to remind conditional watcher * test: write tests for transformation algorithm * refact: update transformation algo * ui: conditionally long poll checks endpoint * refact: add conditional logic for nomad provider refact: update service-fragment model to include owner info ui: differentiate between task and group-level in derived state comp test: add test to document behavior refact: update tests for api change refact: update integration test for API change chore: remove unsused vars chore: elvis operator to protect mirage refact: create refId instead of internalModel refact: update algo refact: update conditional template logic refact: update test for api change: chore: cant use if and not in hbs conditional
2022-08-29 18:04:55 +00:00
);
}
2018-11-06 00:33:33 +00:00
}
}
async model() {
// Preload the job for the allocation since it's required for the breadcrumb trail
try {
const [allocation] = await Promise.all([
super.model(...arguments),
this.store.findAll('namespace'),
]);
const jobId = allocation.belongsTo('job').id();
await this.store.findRecord('job', jobId);
return allocation;
} catch (e) {
const [allocId, transition] = arguments;
if (e?.errors[0]?.detail === 'alloc not found' && !!transition.from) {
this.notifications.add({
title: `Error: Not Found`,
message: `Allocation of id: ${allocId} was not found.`,
color: 'critical',
sticky: true,
});
this.goBackToReferrer(transition.from.name);
} else {
notifyError(this)(e);
}
}
}
goBackToReferrer(referringRoute) {
this.router.transitionTo(referringRoute);
}
@watchRecord('allocation') watch;
@watchNonStoreRecords('allocation') watchHealthChecks;
2022-09-06 15:46:11 +00:00
@collect('watch', 'watchHealthChecks') watchers;
}