fix(deploy): persist replica snapshot before stop for restore on start
Read live deployment replica counts from K8s before scaling to zero, store them on the application as suspendedReplicas, and use that snapshot when resuming so Start restores the pre-stop replica layout. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -240,7 +240,8 @@ export class DeploymentsService {
|
||||
|
||||
async stopDeployment(applicationId: string, userId: string): Promise<Deployment | null> {
|
||||
const app = await this.applicationsService.findOne(applicationId, userId);
|
||||
await this.kubernetesService.suspendApplication(app);
|
||||
const snapshot = await this.kubernetesService.suspendApplication(app);
|
||||
await this.applicationsService.saveSuspendedReplicas(app.id, snapshot);
|
||||
|
||||
const latest = await this.deploymentsRepository.findOne({
|
||||
where: { applicationId },
|
||||
@@ -257,6 +258,7 @@ export class DeploymentsService {
|
||||
async startDeployment(applicationId: string, userId: string): Promise<Deployment | null> {
|
||||
const app = await this.applicationsService.findOne(applicationId, userId);
|
||||
await this.kubernetesService.resumeApplication(app);
|
||||
await this.applicationsService.clearSuspendedReplicas(app.id);
|
||||
|
||||
const latest = await this.deploymentsRepository.findOne({
|
||||
where: { applicationId },
|
||||
|
||||
Reference in New Issue
Block a user