[ui] Show "Scaled Down" as a valid job status when task groups' counts are set to zero (#23829)

* Scaled Down as a status

* Scaled Down as a steady-state job panel status as well

* Test for badge status and changelog
This commit is contained in:
Phil Renaud
2024-08-19 13:45:19 -04:00
committed by GitHub
parent 4aeb279534
commit 5fcec1f8cc
5 changed files with 30 additions and 3 deletions

3
.changelog/23829.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:improvement
ui: Badge added for Scaled Down jobs
```

View File

@@ -205,7 +205,7 @@ export default class JobStatusPanelSteadyComponent extends Component {
/**
* @typedef {Object} CurrentStatus
* @property {"Healthy"|"Failed"|"Degraded"|"Recovering"|"Complete"|"Running"|"Stopped"} label - The current status of the job
* @property {"Healthy"|"Failed"|"Degraded"|"Recovering"|"Complete"|"Running"|"Stopped"|"Scaled Down"} label - The current status of the job
* @property {"highlight"|"success"|"warning"|"critical"|"neutral"} state -
*/
@@ -224,6 +224,13 @@ export default class JobStatusPanelSteadyComponent extends Component {
};
}
if (this.totalAllocs === 0) {
return {
label: 'Scaled Down',
state: 'neutral',
};
}
if (this.job.type === 'batch' || this.job.type === 'sysbatch') {
// If all the allocs are complete, the job is Complete
const completeAllocs = this.allocBlocks.complete?.healthy?.nonCanary;

View File

@@ -90,7 +90,7 @@ export default class Job extends Model {
/**
* @typedef {Object} CurrentStatus
* @property {"Healthy"|"Failed"|"Deploying"|"Degraded"|"Recovering"|"Complete"|"Running"|"Removed"|"Stopped"} label - The current status of the job
* @property {"Healthy"|"Failed"|"Deploying"|"Degraded"|"Recovering"|"Complete"|"Running"|"Removed"|"Stopped"|"Scaled Down"} label - The current status of the job
* @property {"highlight"|"success"|"warning"|"critical"|"neutral"} state -
*/
@@ -226,6 +226,7 @@ export default class Job extends Model {
* - Failed: All allocations are failed, lost, or unplaced
* - Removed: The job appeared in our initial query, but has since been garbage collected
* - Stopped: The job has been manually stopped (and not purged or yet garbage collected) by a user
* - Scaled Down: The job is intentionally scaled down to 0 desired allocations (all task groups have count=0)
* @returns {CurrentStatus}
*/
/**
@@ -248,6 +249,12 @@ export default class Job extends Model {
};
}
// If the job is scaled down to 0 desired allocations, we shouldn't call it "failed";
// we should indicate that it is deliberately set to not have any running parts.
if (totalAllocs === 0) {
return { label: 'Scaled Down', state: 'neutral' };
}
// If the job was requested initially, but a subsequent request for it was
// not found, we can remove links to it but maintain its presence in the list
// until the user specifies they want a refresh

View File

@@ -250,7 +250,7 @@ export default Factory.extend({
groupProps.taskCount = job.groupTaskCount;
}
if (job.groupAllocCount) {
if (job.groupAllocCount !== undefined) {
groupProps.count = job.groupAllocCount;
}

View File

@@ -700,6 +700,13 @@ module('Acceptance | jobs list', function (hooks) {
activeDeployment: true,
});
server.create('job', {
...defaultJobParams,
id: 'scaled-down-job',
groupAllocCount: 0,
status: 'dead',
});
await JobsList.visit();
assert
@@ -732,6 +739,9 @@ module('Acceptance | jobs list', function (hooks) {
assert
.dom('[data-test-job-row="deploying-job"] [data-test-job-status]')
.hasText('Deploying', 'Deploying job is deploying');
assert
.dom('[data-test-job-row="scaled-down-job"] [data-test-job-status]')
.hasText('Scaled Down', 'Scaled down job is scaled down');
await percySnapshot(assert);
});