diff --git a/.changelog/24620.txt b/.changelog/24620.txt new file mode 100644 index 00000000000..f9c4c07e838 --- /dev/null +++ b/.changelog/24620.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fix an issue where system jobs with garbage-collected allocations were showing as Scaled Down +``` diff --git a/ui/app/components/job-status/panel/steady.js b/ui/app/components/job-status/panel/steady.js index d90fb220b0d..e6bc185731a 100644 --- a/ui/app/components/job-status/panel/steady.js +++ b/ui/app/components/job-status/panel/steady.js @@ -224,7 +224,7 @@ export default class JobStatusPanelSteadyComponent extends Component { }; } - if (this.totalAllocs === 0) { + if (this.totalAllocs === 0 && !this.job.hasClientStatus) { return { label: 'Scaled Down', state: 'neutral', @@ -246,7 +246,7 @@ export default class JobStatusPanelSteadyComponent extends Component { } const healthyAllocs = this.allocBlocks.running?.healthy?.nonCanary; - if (healthyAllocs?.length === totalAllocs) { + if (healthyAllocs?.length && healthyAllocs?.length === totalAllocs) { return { label: 'Healthy', state: 'success' }; } diff --git a/ui/app/models/job.js b/ui/app/models/job.js index 007c8a699b5..afc4a12fb60 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -251,7 +251,11 @@ 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) { + // System/Sysbatch jobs (hasClientStatus) get their totalAllocs from expectedRunningAllocCount, + // which is a best-guess-based-on-whats-running number. This means that if there are no current allocs, + // because they've been GC'd, we don't know if they were deliberately scaled down or failed. + // Safer in this case to show as failed rather than imply a deliberate scale-down. + if (totalAllocs === 0 && !this.hasClientStatus) { return { label: 'Scaled Down', state: 'neutral' }; } diff --git a/ui/tests/acceptance/jobs-list-test.js b/ui/tests/acceptance/jobs-list-test.js index 19843a9bc8a..56f488d15b4 100644 --- a/ui/tests/acceptance/jobs-list-test.js +++ b/ui/tests/acceptance/jobs-list-test.js @@ -707,6 +707,14 @@ module('Acceptance | jobs list', function (hooks) { status: 'dead', }); + server.create('job', { + ...defaultJobParams, + id: 'ancient-system-job', + status: 'dead', + type: 'system', + groupAllocCount: 0, + }); + await JobsList.visit(); assert @@ -742,6 +750,9 @@ module('Acceptance | jobs list', function (hooks) { assert .dom('[data-test-job-row="scaled-down-job"] [data-test-job-status]') .hasText('Scaled Down', 'Scaled down job is scaled down'); + assert + .dom('[data-test-job-row="ancient-system-job"] [data-test-job-status]') + .hasText('Failed', 'System job with no allocs is failed'); await percySnapshot(assert); });