[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
This commit is contained in:
Phil Renaud
2024-04-16 15:50:06 -04:00
committed by GitHub
parent 22bfcdecf1
commit 5150adffc0
3 changed files with 38 additions and 4 deletions

3
.changelog/20408.txt Normal file
View File

@@ -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
```

View File

@@ -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)
);
}

View File

@@ -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);