diff --git a/.changelog/25742.txt b/.changelog/25742.txt new file mode 100644 index 000000000..6ec32866c --- /dev/null +++ b/.changelog/25742.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixed a bug where the job list page incorrectly calculated if a job had paused tasks. +``` diff --git a/ui/app/models/job.js b/ui/app/models/job.js index 164ff8dbf..467d99fe4 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -316,15 +316,20 @@ export default class Job extends Model { @attr('boolean') isPack; /** - * A task with a schedule block can have execution paused at specific cron-based times. - * If one is currently paused, an allocation at /statuses will come back with hasPausedTask=true. - * We should represent this to the user in the job row. + * A task with a schedule block can have execution paused at specific + * cron-based times. If an allocation is currently paused and in a pending + * client state, we should represent this to the user in the job row. + * + * Use the allocations client status and the hasPausedTask allocation returned + * at /statuses to determine the correct information. */ get hasPausedTask() { if (!this.allocations) { return false; } - return this.allocations.any((alloc) => alloc.hasPausedTask); + return this.allocations + .filter((alloc) => alloc.clientStatus === 'pending') + .any((alloc) => alloc.hasPausedTask); } // True when the job is the parent periodic or parameterized jobs diff --git a/ui/mirage/factories/allocation.js b/ui/mirage/factories/allocation.js index 548477d50..20f938df2 100644 --- a/ui/mirage/factories/allocation.js +++ b/ui/mirage/factories/allocation.js @@ -229,8 +229,7 @@ export default Factory.extend({ }); allocation.update({ - taskStateIds: - allocation.clientStatus === 'pending' ? [] : states.mapBy('id'), + taskStateIds: states.mapBy('id'), taskResourceIds: resources.mapBy('id'), }); diff --git a/ui/mirage/scenarios/default.js b/ui/mirage/scenarios/default.js index 8bafd27b7..2ead57feb 100644 --- a/ui/mirage/scenarios/default.js +++ b/ui/mirage/scenarios/default.js @@ -173,6 +173,23 @@ function smallCluster(server) { state: 'running', }); + const pausedJobGroups = 2; + const pausedTasksPerGroup = 5; + server.create('job', { + name: 'paused-job', + id: 'paused-job', + namespaceId: 'default', + type: 'service', + withPausedTasks: true, + resourceSpec: Array(pausedJobGroups).fill('M: 256, C: 500'), + groupTaskCount: pausedTasksPerGroup, + shallow: false, + allocStatusDistribution: { + pending: 1, + }, + noActiveDeployment: true, + }); + server.create('policy', { id: 'client-reader', name: 'client-reader', diff --git a/ui/tests/acceptance/allocation-detail-test.js b/ui/tests/acceptance/allocation-detail-test.js index 5f69f44a3..5f323839b 100644 --- a/ui/tests/acceptance/allocation-detail-test.js +++ b/ui/tests/acceptance/allocation-detail-test.js @@ -289,9 +289,10 @@ module('Acceptance | allocation detail', function (hooks) { }); test('when there are no tasks, an empty state is shown', async function (assert) { - // Make sure the allocation is pending in order to ensure there are no tasks - allocation = server.create('allocation', 'withTaskWithPorts', { - clientStatus: 'pending', + allocation = server.create('allocation'); + allocation.update({ + taskStateIds: [], + taskResourceIds: [], }); await Allocation.visit({ id: allocation.id }); diff --git a/ui/tests/acceptance/jobs-list-test.js b/ui/tests/acceptance/jobs-list-test.js index bef3f4f8d..c18588fa1 100644 --- a/ui/tests/acceptance/jobs-list-test.js +++ b/ui/tests/acceptance/jobs-list-test.js @@ -767,7 +767,7 @@ module('Acceptance | jobs list', function (hooks) { createAllocations: true, }); server.create('job', { - name: 'time-based-job ', + name: 'time-based-job', id: 'time-based-job', createAllocations: true, type: 'service', @@ -777,10 +777,11 @@ module('Acceptance | jobs list', function (hooks) { groupAllocCount: 1, groupTaskCount: 1, allocStatusDistribution: { - running: 1, + pending: 1, }, noActiveDeployment: true, - status: 'running', + status: 'pending', + clientStatus: 'pending', noFailedPlacements: true, });