diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 3de3f497..4d889077 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -251,8 +251,17 @@ export class Service { }); if (previousCanonicalDeployment) { + // If all the DNS in the previous canonical deployment request are different from the new deployment request // Send removal request for the previous canonical deployment and delete DB entry - if (previousCanonicalDeployment.url !== deployment.url) { + const previousDnsList = previousCanonicalDeployment.applicationDeploymentRequestData?.dns || ""; + const newDnsList = deployment.applicationDeploymentRequestData?.dns || ""; + + const previousDnsSet = new Set(previousDnsList.split(",").map(item => item.trim())); + const newDnsSet = new Set(newDnsList.split(",").map(item => item.trim())); + + const isMatch = previousDnsSet.size === newDnsSet.size && [...previousDnsSet].every(item => newDnsSet.has(item)); + + if (!isMatch) { await this.laconicRegistry.createApplicationDeploymentRemovalRequest( { deploymentId: @@ -676,6 +685,7 @@ export class Service { deployer: oldDeployment.deployer, }); } + return newDeployment; }