From 99996fcd173b78df0771616ba51f93701647d4d2 Mon Sep 17 00:00:00 2001 From: lilianrong Date: Fri, 23 Aug 2024 13:32:19 +0800 Subject: [PATCH] feat(qrm): fix reclaimed cores topology hints --- .../cpu/dynamicpolicy/policy_hint_handlers.go | 10 +++++++++- .../memory/dynamicpolicy/policy_hint_handlers.go | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go index 6ba161628..bc1c8ea43 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go @@ -86,10 +86,18 @@ func (p *DynamicPolicy) sharedCoresHintHandler(ctx context.Context, func (p *DynamicPolicy) reclaimedCoresHintHandler(ctx context.Context, req *pluginapi.ResourceRequest, ) (*pluginapi.ResourceHintsResponse, error) { + if req == nil { + return nil, fmt.Errorf("got nil request") + } + if util.PodInplaceUpdateResizing(req) { return nil, fmt.Errorf("not support inplace update resize for reclaimed cores") } - return p.sharedCoresHintHandler(ctx, req) + + return util.PackResourceHintsResponse(req, string(v1.ResourceCPU), + map[string]*pluginapi.ListOfTopologyHints{ + string(v1.ResourceCPU): nil, // indicates that there is no numa preference + }) } func (p *DynamicPolicy) dedicatedCoresHintHandler(ctx context.Context, diff --git a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_hint_handlers.go b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_hint_handlers.go index 8412a956a..d4475a86a 100644 --- a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_hint_handlers.go +++ b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_hint_handlers.go @@ -72,12 +72,20 @@ func (p *DynamicPolicy) sharedCoresHintHandler(ctx context.Context, func (p *DynamicPolicy) reclaimedCoresHintHandler(ctx context.Context, req *pluginapi.ResourceRequest, ) (*pluginapi.ResourceHintsResponse, error) { + if req == nil { + return nil, fmt.Errorf("got nil request") + } + if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to memory inplace update resize, but not support reclaimed cores", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("not support inplace update resize for reclaimed cores") } - return p.sharedCoresHintHandler(ctx, req) + + return util.PackResourceHintsResponse(req, string(v1.ResourceMemory), + map[string]*pluginapi.ListOfTopologyHints{ + string(v1.ResourceMemory): nil, // indicates that there is no numa preference + }) } func (p *DynamicPolicy) dedicatedCoresHintHandler(ctx context.Context,