From e3c2ebb949a253329f472d135f1e5d2bf2ec4a91 Mon Sep 17 00:00:00 2001 From: dhavalpiqud Date: Mon, 29 Jun 2026 16:22:50 +0530 Subject: [PATCH] Fix: Deployment validation issue for port and cpu check --- .../src/executors/deploy-template.executor.ts | 8 ++--- .../deployments/deployments.controller.ts | 32 +++++++++++++------ .../deployments/dto/deploy-template.dto.ts | 5 --- .../src/features/deployments/api/index.ts | 19 +++++++---- .../src/features/deployments/types/index.ts | 2 +- .../components/deploy-configuration-form.tsx | 4 +-- .../src/features/templates/types/index.ts | 2 +- console-app/src/pages/deploy-logs-page.tsx | 4 +-- 8 files changed, 44 insertions(+), 32 deletions(-) diff --git a/apps/agent-app/src/executors/deploy-template.executor.ts b/apps/agent-app/src/executors/deploy-template.executor.ts index cfc0376..7a6866b 100644 --- a/apps/agent-app/src/executors/deploy-template.executor.ts +++ b/apps/agent-app/src/executors/deploy-template.executor.ts @@ -704,13 +704,13 @@ export class DeployTemplateExecutor { opts.resolvedConfig, ); - await this.resourceAvailabilityService.assertRamAvailable( - requirements.memoryBytes, - ); - await this.resourceAvailabilityService.assertCpuAvailable( requirements.cpuCores, ); + + await this.resourceAvailabilityService.assertRamAvailable( + requirements.memoryBytes, + ); } else { this.logger.warn( "RAM and CPU availability checks skipped: user confirmed resource override", diff --git a/apps/control-panel-app/src/modules/deployments/deployments.controller.ts b/apps/control-panel-app/src/modules/deployments/deployments.controller.ts index bc44eb9..e979831 100644 --- a/apps/control-panel-app/src/modules/deployments/deployments.controller.ts +++ b/apps/control-panel-app/src/modules/deployments/deployments.controller.ts @@ -9,6 +9,7 @@ import { Param, Patch, Post, + Query, Req, UseGuards, UsePipes, @@ -45,6 +46,7 @@ export class DeploymentsController { async deployCompose( @Req() req: { user: UserEntity }, @Body() body: DeployTemplateDto, + @Query("acknowledgeResourceWarning") acknowledgeResourceWarning?: string, ): Promise<{ message: string; template: string; @@ -100,7 +102,9 @@ export class DeploymentsController { const result = this.deploymentsService.schedulePreparedDeployment( prepared, Boolean(deploymentId), - { skipResourceValidation: body.skipResourceValidation }, + { + skipResourceValidation: acknowledgeResourceWarning === "true", + }, ); const publicUrl = resolvePrimaryServicePublicUrl( @@ -160,6 +164,7 @@ export class DeploymentsController { async deploy( @Req() req: { user: UserEntity }, @Body() body: DeployTemplateDto, + @Query("acknowledgeResourceWarning") acknowledgeResourceWarning?: string, ): Promise<{ message: string; template: string; @@ -213,7 +218,9 @@ export class DeploymentsController { return this.deploymentsService.schedulePreparedDeployment( prepared, Boolean(deploymentId), - { skipResourceValidation: body.skipResourceValidation }, + { + skipResourceValidation: acknowledgeResourceWarning === "true", + }, ); } catch (error) { this.logger.error( @@ -233,6 +240,7 @@ export class DeploymentsController { @Req() req: { user: UserEntity }, @Param("deploymentId") deploymentId: string, @Body() body: DeployTemplateDto, + @Query("acknowledgeResourceWarning") acknowledgeResourceWarning?: string, ): Promise<{ message: string; template: string; @@ -249,14 +257,18 @@ export class DeploymentsController { ); } - return this.deploy(req, { - ...body, - templateSlug: deployment.templateSlug, - deploymentId, - serverId: body.serverId ?? deployment.serverId ?? undefined, - deployOnLocal: - body.deployOnLocal ?? (!body.serverId && !deployment.serverId), - }); + return this.deploy( + req, + { + ...body, + templateSlug: deployment.templateSlug, + deploymentId, + serverId: body.serverId ?? deployment.serverId ?? undefined, + deployOnLocal: + body.deployOnLocal ?? (!body.serverId && !deployment.serverId), + }, + acknowledgeResourceWarning, + ); } catch (error) { this.logger.error( `Redeploy failed: ${error instanceof Error ? error.message : String(error)}`, diff --git a/apps/control-panel-app/src/modules/deployments/dto/deploy-template.dto.ts b/apps/control-panel-app/src/modules/deployments/dto/deploy-template.dto.ts index 1a5b0a7..fa17ad1 100644 --- a/apps/control-panel-app/src/modules/deployments/dto/deploy-template.dto.ts +++ b/apps/control-panel-app/src/modules/deployments/dto/deploy-template.dto.ts @@ -39,9 +39,4 @@ export class DeployTemplateDto { @IsOptional() @IsBoolean() useTraefik?: boolean; - - /** When true, skip RAM/CPU availability checks for this deployment only. */ - @IsOptional() - @IsBoolean() - skipResourceValidation?: boolean; } diff --git a/console-app/src/features/deployments/api/index.ts b/console-app/src/features/deployments/api/index.ts index 45a5918..ca26652 100644 --- a/console-app/src/features/deployments/api/index.ts +++ b/console-app/src/features/deployments/api/index.ts @@ -19,13 +19,18 @@ function responseBody(response: { data: unknown }): Record { export async function deployTemplate( input: DeployTemplateInput, ): Promise { - const response = await apiClient.post("/deployments/compose", { - templateSlug: input.templateSlug, - serverId: input.serverId, - env: input.env ?? {}, - ports: input.ports ?? {}, - skipResourceValidation: input.skipResourceValidation, - }); + const response = await apiClient.post( + "/deployments/compose", + { + templateSlug: input.templateSlug, + serverId: input.serverId, + env: input.env ?? {}, + ports: input.ports ?? {}, + }, + input.acknowledgeResourceWarning + ? { params: { acknowledgeResourceWarning: "true" } } + : undefined, + ); return unwrapServerApiData( responseBody(response), "Failed to start deployment", diff --git a/console-app/src/features/deployments/types/index.ts b/console-app/src/features/deployments/types/index.ts index 939aacb..9d37f08 100644 --- a/console-app/src/features/deployments/types/index.ts +++ b/console-app/src/features/deployments/types/index.ts @@ -38,7 +38,7 @@ export interface DeployTemplateInput { serverId: string; env?: Record; ports?: Record; - skipResourceValidation?: boolean; + acknowledgeResourceWarning?: boolean; } export type DeploymentResourceWarningCode = diff --git a/console-app/src/features/templates/components/deploy-configuration-form.tsx b/console-app/src/features/templates/components/deploy-configuration-form.tsx index 34259d9..b82262e 100644 --- a/console-app/src/features/templates/components/deploy-configuration-form.tsx +++ b/console-app/src/features/templates/components/deploy-configuration-form.tsx @@ -104,7 +104,7 @@ export function DeployConfigurationForm({ function proceedToDeployLogs( env: Record, portValues: Record, - skipResourceValidation = false, + acknowledgeResourceWarning = false, ) { navigate(`/servers/${serverId}/deploy/${template.slug}/logs`, { state: { @@ -113,7 +113,7 @@ export function DeployConfigurationForm({ templateSlug: template.slug, env, ports: portValues, - skipResourceValidation, + acknowledgeResourceWarning, }, }, }); diff --git a/console-app/src/features/templates/types/index.ts b/console-app/src/features/templates/types/index.ts index 0b89d7a..d752ab4 100644 --- a/console-app/src/features/templates/types/index.ts +++ b/console-app/src/features/templates/types/index.ts @@ -25,7 +25,7 @@ export interface DeployTemplateRequest { templateSlug: string; env: Record; ports?: Record; - skipResourceValidation?: boolean; + acknowledgeResourceWarning?: boolean; } export interface DeployFormField { diff --git a/console-app/src/pages/deploy-logs-page.tsx b/console-app/src/pages/deploy-logs-page.tsx index 61751f0..577541c 100644 --- a/console-app/src/pages/deploy-logs-page.tsx +++ b/console-app/src/pages/deploy-logs-page.tsx @@ -25,7 +25,7 @@ import { NotFoundPage } from "./not-found-page"; type PendingDeployLocationState = { deployRequest?: Pick< DeployTemplateRequest, - "env" | "ports" | "templateSlug" | "serverId" | "skipResourceValidation" + "env" | "ports" | "templateSlug" | "serverId" | "acknowledgeResourceWarning" >; }; @@ -109,7 +109,7 @@ export function DeployLogsPage() { serverId, env: pendingDeploy.env, ports: pendingDeploy.ports, - skipResourceValidation: pendingDeploy.skipResourceValidation, + acknowledgeResourceWarning: pendingDeploy.acknowledgeResourceWarning, }) .then((result) => { if (cancelled) return;