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:
@@ -189,6 +189,25 @@ export class ApplicationsService {
|
||||
return this.appsRepository.save(app);
|
||||
}
|
||||
|
||||
async saveSuspendedReplicas(
|
||||
id: string,
|
||||
snapshot: Record<string, number>,
|
||||
): Promise<Application> {
|
||||
const app = await this.findOne(id);
|
||||
app.suspendedReplicas = snapshot;
|
||||
app.suspendedAt = new Date();
|
||||
if (snapshot[app.name] !== undefined) {
|
||||
app.replicas = snapshot[app.name];
|
||||
}
|
||||
return this.appsRepository.save(app);
|
||||
}
|
||||
|
||||
async clearSuspendedReplicas(id: string): Promise<Application> {
|
||||
const app = await this.findOne(id);
|
||||
app.suspendedReplicas = undefined;
|
||||
return this.appsRepository.save(app);
|
||||
}
|
||||
|
||||
async uploadCode(id: string, userId: string, file: Express.Multer.File): Promise<Application> {
|
||||
if (!file) {
|
||||
throw new BadRequestException('No file uploaded');
|
||||
|
||||
Reference in New Issue
Block a user