feat(deploy): remove cluster allocation section from app creation
Drop the admin-only "cluster assignment" UI from the resources & config step of the deploy wizard and the related backend override. App placement is now always decided automatically by the allocator. - frontend: remove cluster/pool selection block, review-step cluster row, clusterMode state, public cluster/pool queries, and clusterId/ poolId from CreateApplicationDto - backend: drop clusterId/poolId override from the create DTO and simplify ApplicationsService.create to always auto-allocate; widen selectClusterForApplication param to keep the fallback path working Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,7 @@ export class ApplicationsController {
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new application' })
|
||||
async create(@Request() req: any, @Body() dto: CreateApplicationDto) {
|
||||
return this.applicationsService.create(req.user.id, dto, req.user.role);
|
||||
return this.applicationsService.create(req.user.id, dto);
|
||||
}
|
||||
|
||||
@Post(':id/upload')
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Application } from './entities/application.entity';
|
||||
import { CreateApplicationDto, UpdateApplicationDto } from './dto/application.dto';
|
||||
import { ClustersService } from '../clusters/clusters.service';
|
||||
import {
|
||||
UserRole,
|
||||
DatabaseType,
|
||||
CustomDomainStatus,
|
||||
AppRuntime,
|
||||
@@ -57,39 +56,17 @@ export class ApplicationsService {
|
||||
throw new BadRequestException('Failed to generate a unique subdomain. Please try again.');
|
||||
}
|
||||
|
||||
async create(userId: string, dto: CreateApplicationDto, userRole?: string): Promise<Application> {
|
||||
async create(userId: string, dto: CreateApplicationDto): Promise<Application> {
|
||||
dto = normalizeCreateApplicationDto(dto);
|
||||
const productType = dto.productType ?? ProductType.APPLICATION;
|
||||
|
||||
// End users and technical staff cannot influence placement; only admins may manually assign.
|
||||
const isAdmin = userRole === UserRole.ADMIN;
|
||||
if (!isAdmin) {
|
||||
if (dto.clusterId || dto.poolId) {
|
||||
this.logger.warn(`Non-admin user ${userId} attempted manual cluster/pool selection - ignoring`);
|
||||
}
|
||||
dto.clusterId = undefined;
|
||||
dto.poolId = undefined;
|
||||
}
|
||||
|
||||
let clusterId = dto.clusterId;
|
||||
let poolId = dto.poolId;
|
||||
let allocationLogId: string | undefined;
|
||||
|
||||
if (isAdmin && clusterId) {
|
||||
await this.clustersService.findOne(clusterId);
|
||||
this.logger.log(`Manual cluster assignment for app "${dto.name}" -> cluster ${clusterId}`);
|
||||
} else {
|
||||
const allocationDto = { ...dto };
|
||||
if (poolId) {
|
||||
allocationDto.poolId = poolId;
|
||||
}
|
||||
const allocation = await this.clustersService.selectClusterForApplication(allocationDto, userId);
|
||||
clusterId = allocation.cluster.id;
|
||||
poolId = allocation.pool?.id || (isAdmin ? poolId : undefined);
|
||||
allocationLogId = allocation.allocationLogId;
|
||||
if (!clusterId) {
|
||||
throw new BadRequestException('No eligible cluster available for this application');
|
||||
}
|
||||
// Placement is always decided automatically by the allocator.
|
||||
const allocation = await this.clustersService.selectClusterForApplication(dto, userId);
|
||||
const clusterId = allocation.cluster.id;
|
||||
const poolId = allocation.pool?.id;
|
||||
const allocationLogId = allocation.allocationLogId;
|
||||
if (!clusterId) {
|
||||
throw new BadRequestException('No eligible cluster available for this application');
|
||||
}
|
||||
|
||||
// Generate database credentials if a database is requested
|
||||
|
||||
@@ -198,16 +198,6 @@ export class CreateApplicationDto {
|
||||
@IsNumber()
|
||||
port?: number;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Admin-only manual cluster override. Ignored for non-admin users.' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
clusterId?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Admin-only pool override. Ignored for non-admin users.' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
poolId?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'www.example.com', description: 'Custom domain for the application (requires additional fee)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -266,7 +266,7 @@ export class ClustersService implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
|
||||
async selectClusterForApplication(
|
||||
dto: CreateApplicationDto,
|
||||
dto: CreateApplicationDto & { poolId?: string },
|
||||
userId: string,
|
||||
options: {
|
||||
excludeClusterIds?: string[];
|
||||
|
||||
Reference in New Issue
Block a user