From 5150adffc0842f4f53cfa252171377a9220d8602 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Tue, 16 Apr 2024 15:50:06 -0400 Subject: [PATCH] [ui] Fix a bug where promotion would be asked with no new canaries (#20408) * Fix a UI bug where promotion would be asked with no new canaries * Because we now make sure of your allocations, our test cases should more accurately reflect a state of a promotable workflow --- .changelog/20408.txt | 3 ++ .../components/job-status/panel/deploying.js | 5 +-- .../components/job-page/service-test.js | 34 +++++++++++++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .changelog/20408.txt diff --git a/.changelog/20408.txt b/.changelog/20408.txt new file mode 100644 index 000000000..8a2dfc387 --- /dev/null +++ b/.changelog/20408.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fix a bug where the UI would prompt a user to promote a deployment with unplaced canaries +``` diff --git a/ui/app/components/job-status/panel/deploying.js b/ui/app/components/job-status/panel/deploying.js index 2f3af84c7..89bb9cc93 100644 --- a/ui/app/components/job-status/panel/deploying.js +++ b/ui/app/components/job-status/panel/deploying.js @@ -42,8 +42,9 @@ export default class JobStatusPanelDeployingComponent extends Component { const relevantAllocs = this.job.allocations.filter( (a) => !a.isOld && a.isCanary && !a.hasBeenRescheduled ); - return relevantAllocs.every( - (a) => a.clientStatus === 'running' && a.isHealthy + return ( + relevantAllocs.length && + relevantAllocs.every((a) => a.clientStatus === 'running' && a.isHealthy) ); } diff --git a/ui/tests/integration/components/job-page/service-test.js b/ui/tests/integration/components/job-page/service-test.js index 0ed4acc10..90156fcab 100644 --- a/ui/tests/integration/components/job-page/service-test.js +++ b/ui/tests/integration/components/job-page/service-test.js @@ -227,11 +227,25 @@ module('Integration | Component | job-page/service', function (hooks) { this.server.create('node'); const mirageJob = makeMirageJob(this.server, { activeDeployment: true }); - await this.store.findAll('job'); + const fullId = JSON.stringify([mirageJob.name, 'default']); + await this.store.findRecord('job', fullId); const job = this.store.peekAll('job').findBy('plainId', mirageJob.id); + this.server.db.jobs.update(mirageJob.id, { + activeDeployment: true, + noDeployments: true, + }); const deployment = await job.get('latestDeployment'); + server.create('allocation', { + jobId: mirageJob.id, + deploymentId: deployment.id, + clientStatus: 'running', + deploymentStatus: { + Healthy: true, + Canary: true, + }, + }); this.setProperties(commonProperties(job)); await render(commonTemplate); @@ -259,9 +273,25 @@ module('Integration | Component | job-page/service', function (hooks) { this.server.create('node'); const mirageJob = makeMirageJob(this.server, { activeDeployment: true }); - await this.store.findAll('job'); + const fullId = JSON.stringify([mirageJob.name, 'default']); + await this.store.findRecord('job', fullId); const job = this.store.peekAll('job').findBy('plainId', mirageJob.id); + this.server.db.jobs.update(mirageJob.id, { + activeDeployment: true, + noDeployments: true, + }); + const deployment = await job.get('latestDeployment'); + + server.create('allocation', { + jobId: mirageJob.id, + deploymentId: deployment.id, + clientStatus: 'running', + deploymentStatus: { + Healthy: true, + Canary: true, + }, + }); this.setProperties(commonProperties(job)); await render(commonTemplate);