Update flow for deleting deployments
This commit is contained in:
parent
5be10b6b0a
commit
6dcee29487
@ -1222,37 +1222,28 @@ export class Service {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Compare deployer in DNS while deleting
|
|
||||||
|
|
||||||
if (deployment && deployment.applicationDeploymentRecordId) {
|
if (deployment && deployment.applicationDeploymentRecordId) {
|
||||||
// If deployment is current, remove deployment for project subdomain as well
|
// If deployment is current, remove deployment for project subdomain as well
|
||||||
if (deployment.isCurrent) {
|
if (deployment.isCurrent) {
|
||||||
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.deployer.baseDomain}`;
|
const dnsDeployment = await this.db.getDeployment({
|
||||||
|
where: {
|
||||||
|
projectId: deployment.project.id,
|
||||||
|
deployer: deployment.deployer,
|
||||||
|
isDNS: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// TODO: Store the latest DNS deployment record
|
if (!dnsDeployment) {
|
||||||
const deploymentRecords =
|
log(`DNS deployment for deployment with id ${deployment.id} not found`);
|
||||||
await this.laconicRegistry.getDeploymentRecordsByFilter({
|
|
||||||
application: deployment.applicationRecordId,
|
|
||||||
url: currentDeploymentURL,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!deploymentRecords.length) {
|
|
||||||
log(
|
|
||||||
`No ApplicationDeploymentRecord found for URL ${currentDeploymentURL} and ApplicationDeploymentRecord id ${deployment.applicationDeploymentRecordId}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiple records are fetched, take the latest record
|
|
||||||
const latestRecord = deploymentRecords
|
|
||||||
.sort((a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime())[0];
|
|
||||||
|
|
||||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||||
deploymentId: latestRecord.id,
|
deploymentId: dnsDeployment.id,
|
||||||
deployerLrn: deployment.deployer.deployerLrn,
|
deployerLrn: dnsDeployment.deployer.deployerLrn,
|
||||||
auctionId: deployment.project.auctionId,
|
auctionId: dnsDeployment.project.auctionId,
|
||||||
payment: deployment.project.txHash
|
payment: dnsDeployment.project.txHash
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user