feat(dns): Enhance DNS management with auto-generated entries and service activation
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user