mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
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 <phil@riotindustries.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 });
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user