Update deletion flow to handle deployments without canonical deployments
This commit is contained in:
parent
2c71b8c95f
commit
027c88e148
@ -1289,13 +1289,38 @@ export class Service {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// If the canonical deployment is not present then query the chain for the deployment record for backwards compatibility
|
||||||
if (!canonicalDeployment) {
|
if (!canonicalDeployment) {
|
||||||
log(`Canonical deployment for deployment with id ${deployment.id} not found`);
|
log(`Canonical deployment for deployment with id ${deployment.id} not found, querying the chain..`);
|
||||||
|
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.deployer.baseDomain}`;
|
||||||
|
|
||||||
|
const deploymentRecords =
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dnsResult =
|
// 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({
|
||||||
|
deploymentId: latestRecord.id,
|
||||||
|
deployerLrn: deployment.deployer.deployerLrn,
|
||||||
|
auctionId: deployment.project.auctionId,
|
||||||
|
payment: deployment.project.txHash
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// If canonical deployment is found in the DB, then send the removal request with that deployment record Id
|
||||||
|
const result =
|
||||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||||
deploymentId: canonicalDeployment.applicationDeploymentRecordId!,
|
deploymentId: canonicalDeployment.applicationDeploymentRecordId!,
|
||||||
deployerLrn: canonicalDeployment.deployer.deployerLrn,
|
deployerLrn: canonicalDeployment.deployer.deployerLrn,
|
||||||
@ -1306,11 +1331,12 @@ export class Service {
|
|||||||
await this.db.updateDeploymentById(canonicalDeployment.id, {
|
await this.db.updateDeploymentById(canonicalDeployment.id, {
|
||||||
status: DeploymentStatus.Deleting,
|
status: DeploymentStatus.Deleting,
|
||||||
applicationDeploymentRemovalRequestId:
|
applicationDeploymentRemovalRequestId:
|
||||||
dnsResult.applicationDeploymentRemovalRequestId,
|
result.applicationDeploymentRemovalRequestId,
|
||||||
applicationDeploymentRemovalRequestData:
|
applicationDeploymentRemovalRequestData:
|
||||||
dnsResult.applicationDeploymentRemovalRequestData,
|
result.applicationDeploymentRemovalRequestData,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const result =
|
const result =
|
||||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||||
|
Loading…
Reference in New Issue
Block a user