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
This commit is contained in:
xusongfu 2022-08-01 15:05:02 +08:00
parent c3835d24c0
commit 6110deace4

View File

@ -110,9 +110,18 @@ export class StepCreate extends StepAction {
title: t('Containers'), 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 = { const cpuQuotaInfo = {
...cpu, ...cpu,
add: cpuCount, add: canAdd ? cpuCount : 0,
name: 'cpu', name: 'cpu',
title: t('CPU'), title: t('CPU'),
type: 'line', type: 'line',
@ -120,7 +129,7 @@ export class StepCreate extends StepAction {
const memoryQuotaInfo = { const memoryQuotaInfo = {
...memory, ...memory,
add: memoryCount, add: canAdd ? memoryCount : 0,
name: 'memory', name: 'memory',
title: t('Memory (MiB)'), title: t('Memory (MiB)'),
type: 'line', type: 'line',
@ -128,7 +137,7 @@ export class StepCreate extends StepAction {
const diskQuotaInfo = { const diskQuotaInfo = {
...disk, ...disk,
add: diskCount, add: canAdd ? diskCount : 0,
name: 'disk', name: 'disk',
title: t('Disk (GiB)'), title: t('Disk (GiB)'),
type: 'line', type: 'line',