Add managed databases and services with billing-aligned upgrades.
Introduce product types for managed PostgreSQL, Redis, and RabbitMQ with a dedicated dashboard, Helm-only deploy pipeline, external access, snapshots with progress, and prorated resource or storage upgrades matching application billing rules. PVCs use an expandable StorageClass with automatic migration when legacy disks cannot resize in place. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -200,9 +200,12 @@ export class ApplicationsController {
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'List my applications' })
|
||||
async findAll(@Request() req: any) {
|
||||
return this.applicationsService.findAllByUser(req.user.id);
|
||||
@ApiOperation({ summary: 'List my applications or managed services' })
|
||||
async findAll(
|
||||
@Request() req: any,
|
||||
@Query('productType') productType?: 'application' | 'managed',
|
||||
) {
|
||||
return this.applicationsService.findAllByUser(req.user.id, { productType });
|
||||
}
|
||||
|
||||
@Get('all')
|
||||
@@ -299,19 +302,30 @@ export class ApplicationsController {
|
||||
// Update in K8s (live)
|
||||
await this.kubernetesService.updateResources(app, dto, workload);
|
||||
|
||||
// Update in DB — only main app resources are stored on the Application entity
|
||||
const updateFields: any = {};
|
||||
const updateFields: Record<string, unknown> = {};
|
||||
if (workload === 'app') {
|
||||
if (dto.cpuRequest) updateFields.cpuRequest = dto.cpuRequest;
|
||||
if (dto.cpuLimit) updateFields.cpuLimit = dto.cpuLimit;
|
||||
if (dto.memoryRequest) updateFields.memoryRequest = dto.memoryRequest;
|
||||
if (dto.memoryLimit) updateFields.memoryLimit = dto.memoryLimit;
|
||||
if (dto.replicas !== undefined) updateFields.replicas = dto.replicas;
|
||||
} else if (workload === 'redis' || workload === 'rabbitmq') {
|
||||
const prev = app.optionalServiceResources?.[workload];
|
||||
updateFields.optionalServiceResources = {
|
||||
...app.optionalServiceResources,
|
||||
[workload]: {
|
||||
cpuRequest: dto.cpuRequest ?? prev?.cpuRequest,
|
||||
cpuLimit: dto.cpuLimit ?? prev?.cpuLimit ?? '200m',
|
||||
memoryRequest: dto.memoryRequest ?? prev?.memoryRequest,
|
||||
memoryLimit: dto.memoryLimit ?? prev?.memoryLimit ?? '256Mi',
|
||||
storageGi: prev?.storageGi ?? (workload === 'redis' ? 1 : 2),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const updated =
|
||||
Object.keys(updateFields).length > 0
|
||||
? await this.applicationsService.update(id, app.userId, updateFields)
|
||||
? await this.applicationsService.update(id, app.userId, updateFields as any)
|
||||
: app;
|
||||
this.logger.log(`Updated resources for ${app.name}: ${JSON.stringify(dto)}`);
|
||||
return updated;
|
||||
|
||||
Reference in New Issue
Block a user