From 46e014c966b09af0c2888683d69b26b88b5dd9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=BE=D0=BC=D1=87=D0=B8=D0=BA=20=D0=9D=D0=B8=D0=BA?= =?UTF-8?q?=D0=B8=D1=82=D0=B0=20=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B5=D0=B2?= =?UTF-8?q?=D0=B8=D1=87?= Date: Thu, 13 Jul 2023 12:26:13 +0300 Subject: [PATCH] Fix panic issue with proportional scheduling Signed-off-by: Nikita --- pkg/scheduler/plugins/predicates/proportional.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/plugins/predicates/proportional.go b/pkg/scheduler/plugins/predicates/proportional.go index bd83d0f54f..469631e220 100644 --- a/pkg/scheduler/plugins/predicates/proportional.go +++ b/pkg/scheduler/plugins/predicates/proportional.go @@ -33,13 +33,13 @@ func checkNodeResourceIsProportional(task *api.TaskInfo, node *api.NodeInfo, pro return status, nil } } + for resourceName, resourceRate := range proportional { if value, found := node.Idle.ScalarResources[resourceName]; found { cpuReserved := value * resourceRate.CPU memoryReserved := value * resourceRate.Memory * 1000 * 1000 - r := node.Idle.Clone() - r = r.Sub(task.Resreq) - if r.MilliCPU < cpuReserved || r.Memory < memoryReserved { + + if node.Idle.MilliCPU-task.Resreq.MilliCPU < cpuReserved || node.Idle.Memory-task.Resreq.Memory < memoryReserved { status.Code = api.Unschedulable status.Reason = fmt.Sprintf("proportional of resource %s check failed", resourceName) return status, fmt.Errorf("proportional of resource %s check failed", resourceName)