Skip to content

Commit e928131

Browse files
jrasellphilrenaud
andauthored
ui: Only show paused icon when allocs in pending state are paused. (#25742)
Jobs were being marked incorectly as having paused allocations when termimal allocations were marked with the paused boolean. The UI should only mark a job as including paused allocations when these paused allocations are in the correct client state, which is pending. --------- Co-authored-by: Phil Renaud <[email protected]>
1 parent 374e987 commit e928131

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

.changelog/25742.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
ui: Fixed a bug where the job list page incorrectly calculated if a job had paused tasks.
3+
```

ui/app/models/job.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,20 @@ export default class Job extends Model {
316316
@attr('boolean') isPack;
317317

318318
/**
319-
* A task with a schedule block can have execution paused at specific cron-based times.
320-
* If one is currently paused, an allocation at /statuses will come back with hasPausedTask=true.
321-
* We should represent this to the user in the job row.
319+
* A task with a schedule block can have execution paused at specific
320+
* cron-based times. If an allocation is currently paused and in a pending
321+
* client state, we should represent this to the user in the job row.
322+
*
323+
* Use the allocations client status and the hasPausedTask allocation returned
324+
* at /statuses to determine the correct information.
322325
*/
323326
get hasPausedTask() {
324327
if (!this.allocations) {
325328
return false;
326329
}
327-
return this.allocations.any((alloc) => alloc.hasPausedTask);
330+
return this.allocations
331+
.filter((alloc) => alloc.clientStatus === 'pending')
332+
.any((alloc) => alloc.hasPausedTask);
328333
}
329334

330335
// True when the job is the parent periodic or parameterized jobs

ui/mirage/factories/allocation.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ export default Factory.extend({
229229
});
230230

231231
allocation.update({
232-
taskStateIds:
233-
allocation.clientStatus === 'pending' ? [] : states.mapBy('id'),
232+
taskStateIds: states.mapBy('id'),
234233
taskResourceIds: resources.mapBy('id'),
235234
});
236235

ui/mirage/scenarios/default.js

+17
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,23 @@ function smallCluster(server) {
173173
state: 'running',
174174
});
175175

176+
const pausedJobGroups = 2;
177+
const pausedTasksPerGroup = 5;
178+
server.create('job', {
179+
name: 'paused-job',
180+
id: 'paused-job',
181+
namespaceId: 'default',
182+
type: 'service',
183+
withPausedTasks: true,
184+
resourceSpec: Array(pausedJobGroups).fill('M: 256, C: 500'),
185+
groupTaskCount: pausedTasksPerGroup,
186+
shallow: false,
187+
allocStatusDistribution: {
188+
pending: 1,
189+
},
190+
noActiveDeployment: true,
191+
});
192+
176193
server.create('policy', {
177194
id: 'client-reader',
178195
name: 'client-reader',

ui/tests/acceptance/allocation-detail-test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ module('Acceptance | allocation detail', function (hooks) {
289289
});
290290

291291
test('when there are no tasks, an empty state is shown', async function (assert) {
292-
// Make sure the allocation is pending in order to ensure there are no tasks
293-
allocation = server.create('allocation', 'withTaskWithPorts', {
294-
clientStatus: 'pending',
292+
allocation = server.create('allocation');
293+
allocation.update({
294+
taskStateIds: [],
295+
taskResourceIds: [],
295296
});
296297
await Allocation.visit({ id: allocation.id });
297298

ui/tests/acceptance/jobs-list-test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ module('Acceptance | jobs list', function (hooks) {
767767
createAllocations: true,
768768
});
769769
server.create('job', {
770-
name: 'time-based-job ',
770+
name: 'time-based-job',
771771
id: 'time-based-job',
772772
createAllocations: true,
773773
type: 'service',
@@ -777,10 +777,11 @@ module('Acceptance | jobs list', function (hooks) {
777777
groupAllocCount: 1,
778778
groupTaskCount: 1,
779779
allocStatusDistribution: {
780-
running: 1,
780+
pending: 1,
781781
},
782782
noActiveDeployment: true,
783-
status: 'running',
783+
status: 'pending',
784+
clientStatus: 'pending',
784785
noFailedPlacements: true,
785786
});
786787

0 commit comments

Comments
 (0)