feat(dns): Enhance DNS management with auto-generated entries and service activation

This commit is contained in:
2025-09-10 15:38:42 +00:00
parent 6a447369f8
commit fd1da01a3f
6 changed files with 190 additions and 1 deletions

View File

@@ -181,8 +181,16 @@ export class DeploymentManager {
throw new Error('Deployment not found');
}
const serviceId = deployment.serviceId;
await deployment.delete();
// Check if this was the last deployment for the service
const remainingDeployments = await this.getDeploymentsForService(serviceId);
if (remainingDeployments.length === 0) {
// Deactivate DNS entries if no more deployments exist
await this.cloudlyRef.dnsManager.deactivateServiceDnsEntries(serviceId);
}
return {
success: true,
};
@@ -281,7 +289,7 @@ export class DeploymentManager {
nodeId: string,
version: string = 'latest'
): Promise<Deployment> {
return await Deployment.createDeployment({
const deployment = await Deployment.createDeployment({
serviceId,
nodeId,
version,
@@ -289,6 +297,19 @@ export class DeploymentManager {
deployedAt: Date.now(),
deploymentLog: [`Deployment created at ${new Date().toISOString()}`],
});
// Activate DNS entries for the service
await this.cloudlyRef.dnsManager.activateServiceDnsEntries(serviceId);
// Get the node's IP address and update DNS entries
const node = await this.cloudlyRef.nodeManager.CClusterNode.getInstance({
id: nodeId,
});
if (node && node.data.publicIp) {
await this.cloudlyRef.dnsManager.updateServiceDnsEntriesIp(serviceId, node.data.publicIp);
}
return deployment;
}
public async start() {