From 6110deace494772bb8ddd62a7e130b53a667f494 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Mon, 1 Aug 2022 15:05:02 +0800 Subject: [PATCH] fix: fix the add value of quota in zun containers Set the add value to 0 if the input value is greater than the left value Change-Id: If15b10290bc7c34c7e51ec6d7ef2c47fcfdee6c5 --- .../Containers/actions/StepCreate/index.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx b/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx index ee505b28..2651b820 100644 --- a/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx +++ b/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx @@ -110,9 +110,18 @@ export class StepCreate extends StepAction { title: t('Containers'), }; + const { left: cpuLeft = 0 } = cpu; + const { left: memoryLeft = 0 } = memory; + const { left: diskLeft = 0 } = disk; + const canAdd = + left && + (cpuLeft === -1 || cpuCount <= cpuLeft) && + (memoryLeft === -1 || memoryCount <= memoryLeft) && + (diskLeft === -1 || diskCount <= diskLeft); + const cpuQuotaInfo = { ...cpu, - add: cpuCount, + add: canAdd ? cpuCount : 0, name: 'cpu', title: t('CPU'), type: 'line', @@ -120,7 +129,7 @@ export class StepCreate extends StepAction { const memoryQuotaInfo = { ...memory, - add: memoryCount, + add: canAdd ? memoryCount : 0, name: 'memory', title: t('Memory (MiB)'), type: 'line', @@ -128,7 +137,7 @@ export class StepCreate extends StepAction { const diskQuotaInfo = { ...disk, - add: diskCount, + add: canAdd ? diskCount : 0, name: 'disk', title: t('Disk (GiB)'), type: 'line',