From 16e98ecce37362d5028770aa9a3d20edfd7ec687 Mon Sep 17 00:00:00 2001 From: kingeasternsun Date: Wed, 11 Jan 2023 14:49:39 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20style:=20replace=200,=20-1=20wit?= =?UTF-8?q?h=20Zero,Infinity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kingeasternsun --- pkg/scheduler/api/resource_info.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/scheduler/api/resource_info.go b/pkg/scheduler/api/resource_info.go index 00b6ea4651..647ae0cdad 100644 --- a/pkg/scheduler/api/resource_info.go +++ b/pkg/scheduler/api/resource_info.go @@ -476,12 +476,12 @@ func (r *Resource) Diff(rr *Resource, defaultValue DimensionDefaultValue) (*Reso decreasedVal.ScalarResources = make(map[v1.ResourceName]float64) for lName, lQuant := range leftRes.ScalarResources { rQuant := rightRes.ScalarResources[lName] - if lQuant == -1 { - increasedVal.ScalarResources[lName] = -1 + if lQuant == float64(Infinity) { + increasedVal.ScalarResources[lName] = lQuant continue } - if rQuant == -1 { - decreasedVal.ScalarResources[lName] = -1 + if rQuant == float64(Infinity) { + decreasedVal.ScalarResources[lName] = rQuant continue } if lQuant > rQuant { @@ -563,22 +563,14 @@ func (r *Resource) setDefaultValue(leftResource, rightResource *Resource, defaul for resourceName := range leftResource.ScalarResources { _, ok := rightResource.ScalarResources[resourceName] if !ok { - if defaultValue == Zero { - rightResource.ScalarResources[resourceName] = 0 - } else if defaultValue == Infinity { - rightResource.ScalarResources[resourceName] = -1 - } + rightResource.ScalarResources[resourceName] = float64(defaultValue) } } for resourceName := range rightResource.ScalarResources { _, ok := leftResource.ScalarResources[resourceName] if !ok { - if defaultValue == Zero { - leftResource.ScalarResources[resourceName] = 0 - } else if defaultValue == Infinity { - leftResource.ScalarResources[resourceName] = -1 - } + leftResource.ScalarResources[resourceName] = float64(defaultValue) } } }