diff --git a/ui/app/routes/allocations/allocation.js b/ui/app/routes/allocations/allocation.js index 9a73e184a..093285283 100644 --- a/ui/app/routes/allocations/allocation.js +++ b/ui/app/routes/allocations/allocation.js @@ -8,7 +8,9 @@ import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils'; export default Route.extend(WithWatchers, { startWatchers(controller, model) { - controller.set('watcher', this.get('watch').perform(model)); + if (model) { + controller.set('watcher', this.get('watch').perform(model)); + } }, // Allocation breadcrumbs extend from job / task group breadcrumbs diff --git a/ui/app/routes/allocations/allocation/task.js b/ui/app/routes/allocations/allocation/task.js index c33797290..d06a7b978 100644 --- a/ui/app/routes/allocations/allocation/task.js +++ b/ui/app/routes/allocations/allocation/task.js @@ -17,16 +17,19 @@ export default Route.extend({ model({ name }) { const allocation = this.modelFor('allocations.allocation'); - if (allocation) { - const task = allocation.get('states').findBy('name', name); - if (task) { - return task; - } + // If there is no allocation, then there is no task. + // Let the allocation route handle the 404 error. + if (!allocation) return; + const task = allocation.get('states').findBy('name', name); + + if (!task) { const err = new EmberError(`Task ${name} not found for allocation ${allocation.get('id')}`); err.code = '404'; this.controllerFor('application').set('error', err); } + + return task; }, }); diff --git a/ui/app/routes/allocations/allocation/task/logs.js b/ui/app/routes/allocations/allocation/task/logs.js index 399258f21..3b5ad2312 100644 --- a/ui/app/routes/allocations/allocation/task/logs.js +++ b/ui/app/routes/allocations/allocation/task/logs.js @@ -3,6 +3,6 @@ import Route from '@ember/routing/route'; export default Route.extend({ model() { const task = this._super(...arguments); - return task.get('allocation.node').then(() => task); + return task && task.get('allocation.node').then(() => task); }, }); diff --git a/ui/app/routes/clients/client.js b/ui/app/routes/clients/client.js index 9e2493030..8af737503 100644 --- a/ui/app/routes/clients/client.js +++ b/ui/app/routes/clients/client.js @@ -30,8 +30,10 @@ export default Route.extend(WithWatchers, { }, startWatchers(controller, model) { - controller.set('watchModel', this.get('watch').perform(model)); - controller.set('watchAllocations', this.get('watchAllocations').perform(model)); + if (model) { + controller.set('watchModel', this.get('watch').perform(model)); + controller.set('watchAllocations', this.get('watchAllocations').perform(model)); + } }, watch: watchRecord('node'),