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:
@@ -74,6 +74,8 @@ export class AppLifecycleService implements OnModuleInit, OnModuleDestroy {
|
||||
if (app.latestImageTag) {
|
||||
try {
|
||||
await this.kubernetesService.resumeApplication(app);
|
||||
app.suspendedReplicas = undefined;
|
||||
await this.appRepo.save(app);
|
||||
this.logger.log(`Reactivated ${app.name} — resumed with ${app.replicas} replicas, expires ${expiresAt.toISOString()}`);
|
||||
} catch (e: any) {
|
||||
this.logger.warn(`Failed to resume ${app.name} on reactivation: ${e.message}`);
|
||||
@@ -138,7 +140,11 @@ export class AppLifecycleService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
// Suspend: scale app and database to 0
|
||||
try {
|
||||
await this.kubernetesService.suspendApplication(app);
|
||||
const snapshot = await this.kubernetesService.suspendApplication(app);
|
||||
app.suspendedReplicas = snapshot;
|
||||
if (snapshot[app.name] !== undefined) {
|
||||
app.replicas = snapshot[app.name];
|
||||
}
|
||||
} catch (e: any) {
|
||||
this.logger.warn(`Failed to suspend ${app.name} in K8s: ${e.message}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user