diff --git a/go.mod b/go.mod index 83c2402918..b2370a3f32 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/google/uuid v1.3.0 github.com/h2non/gock v1.2.0 github.com/klauspost/cpuid/v2 v2.2.6 - github.com/kubewharf/katalyst-api v0.5.1-0.20240816033534-930640a4d608 + github.com/kubewharf/katalyst-api v0.5.1-0.20240820031712-7c1239991078 github.com/montanaflynn/stats v0.7.1 github.com/opencontainers/runc v1.1.6 github.com/opencontainers/selinux v1.10.0 diff --git a/go.sum b/go.sum index 3771f2ffdc..8e788129c3 100644 --- a/go.sum +++ b/go.sum @@ -568,8 +568,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubewharf/katalyst-api v0.5.1-0.20240816033534-930640a4d608 h1:9e+TkjTyn4IKvtcqJaxxsiHQkx0DyKbrWcPf3zcbUhY= -github.com/kubewharf/katalyst-api v0.5.1-0.20240816033534-930640a4d608/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k= +github.com/kubewharf/katalyst-api v0.5.1-0.20240820031712-7c1239991078 h1:CSBXQOe0AzlWcGaww8uqOUDu+/4bL3hVNBz86oziOis= +github.com/kubewharf/katalyst-api v0.5.1-0.20240820031712-7c1239991078/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k= github.com/kubewharf/kubelet v1.24.6-kubewharf.9 h1:jOTYZt7h/J7I8xQMKMUcJjKf5UFBv37jHWvNp5VRFGc= github.com/kubewharf/kubelet v1.24.6-kubewharf.9/go.mod h1:MxbSZUx3wXztFneeelwWWlX7NAAStJ6expqq7gY2J3c= github.com/kyoh86/exportloopref v0.1.7/go.mod h1:h1rDl2Kdj97+Kwh4gdz3ujE7XHmH51Q0lUiZ1z4NLj8= diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy.go index a0eee5c430..6a3f49dd5d 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy.go @@ -663,7 +663,7 @@ func (p *DynamicPolicy) GetTopologyHints(ctx context.Context, return nil, fmt.Errorf("getReqQuantityFromResourceReq failed with error: %v", err) } - general.InfoS("GetTopologyHints called", + general.InfoS("called", "podNamespace", req.PodNamespace, "podName", req.PodName, "containerName", req.ContainerName, @@ -746,7 +746,7 @@ func (p *DynamicPolicy) Allocate(ctx context.Context, return nil, fmt.Errorf("getReqQuantityFromResourceReq failed with error: %v", err) } - general.InfoS("Allocate called", + general.InfoS("called", "podNamespace", req.PodNamespace, "podName", req.PodName, "containerName", req.ContainerName, @@ -830,7 +830,7 @@ func (p *DynamicPolicy) Allocate(ctx context.Context, }() allocationInfo := p.state.GetAllocationInfo(req.PodUid, req.ContainerName) - if allocationInfo != nil && allocationInfo.OriginalAllocationResult.Size() >= reqInt && !util.PodIsInVPAResizing(req) { + if allocationInfo != nil && allocationInfo.OriginalAllocationResult.Size() >= reqInt && !util.PodInplaceUpdateResizing(req) { general.InfoS("already allocated and meet requirement", "podNamespace", req.PodNamespace, "podName", req.PodName, @@ -1150,7 +1150,7 @@ func (p *DynamicPolicy) getContainerRequestedCores(allocationInfo *state.Allocat // if there is these two annotations in memory state, it is a new pod, // we don't need to check the pod request from podWatcher if allocationInfo.Annotations[consts.PodAnnotationAggregatedRequestsKey] != "" || - allocationInfo.Annotations[consts.PodAnnotationVPAResizingKey] != "" { + allocationInfo.Annotations[consts.PodAnnotationInplaceUpdateResizingKey] != "" { return allocationInfo.RequestQuantity } if state.CheckNUMABinding(allocationInfo) { @@ -1176,7 +1176,7 @@ func (p *DynamicPolicy) getContainerRequestedCores(allocationInfo *state.Allocat } func (p *DynamicPolicy) checkNormalShareCoresCpuResource(req *pluginapi.ResourceRequest) (bool, error) { - _, reqFloat64, err := util.GetQuantityFromResourceReq(req) + _, reqFloat64, err := util.GetPodAggregatedRequestResource(req) if err != nil { return false, fmt.Errorf("GetQuantityFromResourceReq failed with error: %v", err) } @@ -1184,12 +1184,15 @@ func (p *DynamicPolicy) checkNormalShareCoresCpuResource(req *pluginapi.Resource shareCoresAllocated := reqFloat64 podEntries := p.state.GetPodEntries() for podUid, podEntry := range podEntries { + if podEntry.IsPoolEntry() { + continue + } if podUid == req.PodUid { continue } for _, allocation := range podEntry { // shareCoresAllocated should involve both main and sidecar containers - if allocation.QoSLevel == consts.PodAnnotationQoSLevelSharedCores && !allocation.CheckNumaBinding() { + if state.CheckShared(allocation) && !state.CheckNUMABinding(allocation) { shareCoresAllocated += p.getContainerRequestedCores(allocation) } } diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_allocation_handlers.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_allocation_handlers.go index 7644cd72af..6df549ebd6 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_allocation_handlers.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_allocation_handlers.go @@ -92,16 +92,6 @@ func (p *DynamicPolicy) sharedCoresWithoutNUMABindingAllocationHandler(_ context req.PodNamespace, req.PodName, req.ContainerName, err) return nil, fmt.Errorf("updateAllocationInfoByReq failed with error: %v", err) } - if util.PodIsInVPAResizing(req) { - if allocationInfo == nil { - general.Errorf("pod: %s/%s, container: %s request to VPA resize, but not allocation info", - req.PodNamespace, req.PodName, req.ContainerName) - return nil, fmt.Errorf("no allocation info to VPA resize") - } - general.Infof("pod: %s/%s, container: %s request to VPA resize (%.02f->%.02f)", - req.PodNamespace, req.PodName, req.ContainerName, allocationInfo.RequestQuantity, reqFloat64) - allocationInfo.RequestQuantity = reqFloat64 - } if allocationInfo == nil { general.Infof("pod: %s/%s, container: %s is met firstly, do ramp up with pooled cpus: %s", @@ -150,7 +140,7 @@ func (p *DynamicPolicy) sharedCoresWithoutNUMABindingAllocationHandler(_ context } } } else if allocationInfo.RampUp { - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s is still in ramp up, not allow to VPA resize", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("pod is still ramp up, not allow to VPA resize") @@ -164,16 +154,20 @@ func (p *DynamicPolicy) sharedCoresWithoutNUMABindingAllocationHandler(_ context allocationInfo.TopologyAwareAssignments = pooledCPUsTopologyAwareAssignments allocationInfo.OriginalTopologyAwareAssignments = machine.DeepcopyCPUAssignment(pooledCPUsTopologyAwareAssignments) } else { - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { + general.Infof("pod: %s/%s, container: %s request to VPA resize (%.02f->%.02f)", + req.PodNamespace, req.PodName, req.ContainerName, allocationInfo.RequestQuantity, reqFloat64) + allocationInfo.RequestQuantity = reqFloat64 + p.state.SetAllocationInfo(allocationInfo.PodUid, allocationInfo.ContainerName, allocationInfo) - _, err := p.doAndCheckPutAllocationInfoPodVPAResizingAware(originAllocationInfo, allocationInfo, false, true) + _, err := p.doAndCheckPutAllocationInfoPodResizingAware(originAllocationInfo, allocationInfo, false, true) if err != nil { - general.Errorf("pod: %s/%s, container: %s doAndCheckPutAllocationInfoPodVPAResizingAware failed: %q", + general.Errorf("pod: %s/%s, container: %s doAndCheckPutAllocationInfoPodResizingAware failed: %q", req.PodNamespace, req.PodName, req.ContainerName, err) + p.state.SetAllocationInfo(originAllocationInfo.PodUid, originAllocationInfo.ContainerName, originAllocationInfo) return nil, err } } else { - // FIXME when reach here? _, err := p.doAndCheckPutAllocationInfo(allocationInfo, true) if err != nil { general.Errorf("pod: %s/%s, container: %s doAndCheckPutAllocationInfo failed: %q", @@ -216,7 +210,7 @@ func (p *DynamicPolicy) reclaimedCoresAllocationHandler(_ context.Context, return nil, fmt.Errorf("reclaimedCoresAllocationHandler got nil request") } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { return nil, fmt.Errorf("not support VPA resize for reclaimed cores") } @@ -307,7 +301,7 @@ func (p *DynamicPolicy) dedicatedCoresAllocationHandler(ctx context.Context, return nil, fmt.Errorf("dedicatedCoresAllocationHandler got nil req") } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { return nil, fmt.Errorf("not support VPA resize for dedicated cores") } @@ -638,7 +632,7 @@ func (p *DynamicPolicy) allocateSharedNumaBindingCPUs(req *pluginapi.ResourceReq RequestQuantity: reqFloat64, } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { originAllocationInfo := p.state.GetAllocationInfo(allocationInfo.PodUid, allocationInfo.ContainerName) if originAllocationInfo == nil { general.Errorf("pod: %s/%s, container: %s request to cpu VPA resize alloation, but no origin allocation info, reject it", @@ -649,10 +643,11 @@ func (p *DynamicPolicy) allocateSharedNumaBindingCPUs(req *pluginapi.ResourceReq general.Infof("pod: %s/%s, container: %s request to cpu VPA resize allocation (%.02f->%.02f)", req.PodNamespace, req.PodName, req.ContainerName, originAllocationInfo.RequestQuantity, allocationInfo.RequestQuantity) p.state.SetAllocationInfo(allocationInfo.PodUid, allocationInfo.ContainerName, allocationInfo) - checkedAllocationInfo, err := p.doAndCheckPutAllocationInfoPodVPAResizingAware(originAllocationInfo, allocationInfo, false, true) + checkedAllocationInfo, err := p.doAndCheckPutAllocationInfoPodResizingAware(originAllocationInfo, allocationInfo, false, true) if err != nil { - general.Errorf("pod: %s/%s, container: %s request to cpu VPA resize allocation, but doAndCheckPutAllocationInfoPodVPAResizingAware failed: %q", + general.Errorf("pod: %s/%s, container: %s request to cpu VPA resize allocation, but doAndCheckPutAllocationInfoPodResizingAware failed: %q", req.PodNamespace, req.PodName, req.ContainerName, err) + p.state.SetAllocationInfo(originAllocationInfo.PodUid, originAllocationInfo.ContainerName, originAllocationInfo) return nil, fmt.Errorf("doAndCheckPutAllocationInfo failed with error: %v", err) } return checkedAllocationInfo, nil @@ -672,14 +667,14 @@ func (p *DynamicPolicy) putAllocationsAndAdjustAllocationEntries(allocationInfos return p.putAllocationsAndAdjustAllocationEntriesVpaAware(nil, allocationInfos, incrByReq, false) } -func (p *DynamicPolicy) putAllocationsAndAdjustAllocationEntriesVpaAware(originAllocationInfos, allocationInfos []*state.AllocationInfo, incrByReq, podIsInVpaResize bool) error { +func (p *DynamicPolicy) putAllocationsAndAdjustAllocationEntriesVpaAware(originAllocationInfos, allocationInfos []*state.AllocationInfo, incrByReq, podInplaceUpdateResizing bool) error { if len(allocationInfos) == 0 { return nil } - if podIsInVpaResize { + if podInplaceUpdateResizing { if len(originAllocationInfos) != 1 && len(allocationInfos) != 1 { general.Errorf("cannot adjust allocation entries for invalid allocation infos") - return nil + return fmt.Errorf("invalid vpa allocation infos length") } } @@ -713,7 +708,7 @@ func (p *DynamicPolicy) putAllocationsAndAdjustAllocationEntriesVpaAware(originA } poolsQuantityMap = machine.ParseCPUAssignmentQuantityMap(csetMap) - if podIsInVpaResize { + if podInplaceUpdateResizing { // adjust pool resize originAllocationInfo := originAllocationInfos[0] allocationInfo := allocationInfos[0] @@ -744,8 +739,8 @@ func (p *DynamicPolicy) putAllocationsAndAdjustAllocationEntriesVpaAware(originA return fmt.Errorf("GetSharedQuantityMapFromPodEntries failed with error: %v", err) } - if incrByReq || podIsInVpaResize { - if podIsInVpaResize { + if incrByReq || podInplaceUpdateResizing { + if podInplaceUpdateResizing { general.Infof("pod: %s/%s, container: %s request to re-calc pool size for cpu VPA resize", allocationInfos[0].PodNamespace, allocationInfos[0].PodName, allocationInfos[0].ContainerName) } @@ -1684,13 +1679,13 @@ func (p *DynamicPolicy) shouldSharedCoresRampUp(podUID string) bool { } } -func (p *DynamicPolicy) doAndCheckPutAllocationInfoPodVPAResizingAware(originAllocationInfo, allocationInfo *state.AllocationInfo, incrByReq, podIsInVPAResizing bool) (*state.AllocationInfo, error) { +func (p *DynamicPolicy) doAndCheckPutAllocationInfoPodResizingAware(originAllocationInfo, allocationInfo *state.AllocationInfo, incrByReq, podInplaceUpdateResizing bool) (*state.AllocationInfo, error) { if allocationInfo == nil { return nil, fmt.Errorf("doAndCheckPutAllocationInfo got nil allocationInfo") } // need to adjust pools and putAllocationsAndAdjustAllocationEntries will set the allocationInfo after adjusted - err := p.putAllocationsAndAdjustAllocationEntriesVpaAware([]*state.AllocationInfo{originAllocationInfo}, []*state.AllocationInfo{allocationInfo}, incrByReq, podIsInVPAResizing) + err := p.putAllocationsAndAdjustAllocationEntriesVpaAware([]*state.AllocationInfo{originAllocationInfo}, []*state.AllocationInfo{allocationInfo}, incrByReq, podInplaceUpdateResizing) if err != nil { general.Errorf("pod: %s/%s, container: %s putAllocationsAndAdjustAllocationEntriesVpaAware failed with error: %v", allocationInfo.PodNamespace, allocationInfo.PodName, allocationInfo.ContainerName, err) @@ -1708,7 +1703,7 @@ func (p *DynamicPolicy) doAndCheckPutAllocationInfoPodVPAResizingAware(originAll } func (p *DynamicPolicy) doAndCheckPutAllocationInfo(allocationInfo *state.AllocationInfo, incrByReq bool) (*state.AllocationInfo, error) { - return p.doAndCheckPutAllocationInfoPodVPAResizingAware(nil, allocationInfo, incrByReq, false) + return p.doAndCheckPutAllocationInfoPodResizingAware(nil, allocationInfo, incrByReq, false) } func (p *DynamicPolicy) getReclaimOverlapShareRatio(entries state.PodEntries) (map[string]float64, error) { 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 6fd17a01dd..73efaf3750 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go @@ -52,33 +52,24 @@ func (p *DynamicPolicy) sharedCoresHintHandler(ctx context.Context, return p.sharedCoresWithNUMABindingHintHandler(ctx, req) } - ok, err := p.checkNormalShareCoresCpuResource(req) - if err != nil { - general.Errorf("failed to check share cores cpu resource for pod: %s/%s, container: %s", - req.PodNamespace, req.PodName, req.ContainerName) - return nil, fmt.Errorf("failed to check share cores cpu resource: %q", err) - } - - if !ok { - _ = p.emitter.StoreInt64(util.MetricNameShareCoresNoEnoughResourceFailed, 1, metrics.MetricTypeNameCount, []metrics.MetricTag{ - { - Key: "resource", - Val: "cpu", - }, - { - Key: "userPodNs", - Val: req.PodNamespace, - }, - { - Key: "userPodName", - Val: req.PodName, - }, - { - Key: "userContainerName", - Val: req.ContainerName, - }, - }...) - return nil, fmt.Errorf("no enough cpu resource") + // TODO: support sidecar follow main container for normal share cores in future + if req.ContainerType == pluginapi.ContainerType_MAIN { + ok, err := p.checkNormalShareCoresCpuResource(req) + if err != nil { + general.Errorf("failed to check share cores cpu resource for pod: %s/%s, container: %s", + req.PodNamespace, req.PodName, req.ContainerName) + return nil, fmt.Errorf("failed to check share cores cpu resource: %q", err) + } + + if !ok { + _ = p.emitter.StoreInt64(util.MetricNameShareCoresNoEnoughResourceFailed, 1, metrics.MetricTypeNameCount, metrics.ConvertMapToTags(map[string]string{ + "resource": v1.ResourceCPU.String(), + "podNamespace": req.PodNamespace, + "podName": req.PodName, + "containerName": req.ContainerName, + })...) + return nil, fmt.Errorf("no enough cpu resource") + } } return util.PackResourceHintsResponse(req, string(v1.ResourceCPU), @@ -90,7 +81,7 @@ func (p *DynamicPolicy) sharedCoresHintHandler(ctx context.Context, func (p *DynamicPolicy) reclaimedCoresHintHandler(ctx context.Context, req *pluginapi.ResourceRequest, ) (*pluginapi.ResourceHintsResponse, error) { - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { return nil, fmt.Errorf("not support VPA for reclaimed cores") } return p.sharedCoresHintHandler(ctx, req) @@ -103,7 +94,7 @@ func (p *DynamicPolicy) dedicatedCoresHintHandler(ctx context.Context, return nil, fmt.Errorf("dedicatedCoresHintHandler got nil req") } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { return nil, fmt.Errorf("not support VPA for dedicated cores") } @@ -554,9 +545,11 @@ func (p *DynamicPolicy) sharedCoresWithNUMABindingHintHandler(_ context.Context, if allocationInfo != nil { hints = cpuutil.RegenerateHints(allocationInfo, reqInt) - // regenerateHints failed. need to clear container record and re-calculate. - if hints == nil { - // [TODO]: generateMachineStateFromPodEntries adapts to shared_cores with numa_binding + // clear the current container and regenerate machine state in follow cases: + // 1. regenerateHints failed. + // 2. the container is inplace update resizing. + // hints it as a new container + if hints == nil || util.PodInplaceUpdateResizing(req) { machineState, err = p.clearContainerAndRegenerateMachineState(podEntries, req) if err != nil { general.Errorf("pod: %s/%s, container: %s clearContainerAndRegenerateMachineState failed with error: %v", @@ -564,46 +557,31 @@ func (p *DynamicPolicy) sharedCoresWithNUMABindingHintHandler(_ context.Context, return nil, fmt.Errorf("GenerateMachineStateFromPodEntries failed with error: %v", err) } } - } else if util.PodIsInVPAResizing(req) { + } else if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to cpu VPA resize, but no origin allocation info", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("no origin allocation info") } - general.Infof("pod: %s/%s, container: %s, VPA: %v", req.PodNamespace, req.PodName, req.ContainerName, util.PodIsInVPAResizing(req)) - if util.PodIsInVPAResizing(req) { + general.Infof("pod: %s/%s, container: %s, VPA: %v", req.PodNamespace, req.PodName, req.ContainerName, util.PodInplaceUpdateResizing(req)) + if util.PodInplaceUpdateResizing(req) { numaset := allocationInfo.GetAllocationResultNUMASet() if numaset.Size() != 1 { general.Errorf("pod: %s/%s, container: %s is snb, but its numa set size is %d", req.PodNamespace, req.PodName, req.ContainerName, numaset.Size()) + return nil, fmt.Errorf("snb port not support cross numa") } nodeID := numaset.ToSliceInt()[0] availableCPUQuantity := machineState[nodeID].GetAvailableCPUQuantity(p.reservedCPUs) - allocatedReq, ok := allocationInfo.GetPodAggregatedRequest() - if !ok { - allocatedReq = 0 - containerEntries := podEntries[req.PodUid] - for _, containerEntry := range containerEntries { - allocatedReq += containerEntry.RequestQuantity - } - } - allocatedReqInt := int(allocatedReq) - general.Infof("pod: %s/%s, container: %s request cpu VPA on numa %d (available: %d, allocated: %d, request: %d)", - req.PodNamespace, req.PodName, req.ContainerName, nodeID, availableCPUQuantity, allocatedReqInt, reqInt) - if allocatedReqInt < reqInt && reqInt-allocatedReqInt > availableCPUQuantity { // no left resource to scale out + general.Infof("pod: %s/%s, container: %s request cpu VPA on numa %d (available: %d, request: %d)", + req.PodNamespace, req.PodName, req.ContainerName, nodeID, availableCPUQuantity, reqInt) + if reqInt > availableCPUQuantity { // no left resource to scale out general.Infof("pod: %s/%s, container: %s request cpu VPA, but no enough resource for it in current NUMA, checking migratable", req.PodNamespace, req.PodName, req.ContainerName) - // FIXME move isVPAMigratable to config + // TODO move isVPAMigratable to config isVpaMigratable := false if isVpaMigratable { - machineState, err = p.clearContainerAndRegenerateMachineState(podEntries, req) - if err != nil { - general.Errorf("pod: %s/%s, container: %s clearContainerAndRegenerateMachineState failed in VPA mode with error: %v", - req.PodNamespace, req.PodName, req.ContainerName, err) - return nil, err - } - general.Infof("pod: %s/%s, container: %s request VPA and no enough resource in current NUMA, try to migrate it to new NUMA", req.PodNamespace, req.PodName, req.ContainerName) var calculateErr error @@ -640,7 +618,6 @@ func (p *DynamicPolicy) clearContainerAndRegenerateMachineState(podEntries state } var err error - // [TODO]: generateMachineStateFromPodEntries adapts to shared_cores with numa_binding machineState, err := generateMachineStateFromPodEntries(p.machineInfo.CPUTopology, podEntries) if err != nil { return nil, fmt.Errorf("GenerateMachineStateFromPodEntries failed with error: %v", err) diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_test.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_test.go index b0f6c7054f..605ac564e5 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_test.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_test.go @@ -5196,7 +5196,7 @@ func TestSNBAdmitWithSidecarReallocate(t *testing.T) { dynamicPolicy.podAnnotationKeptKeys = []string{ consts.PodAnnotationMemoryEnhancementNumaBinding, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/state.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/state.go index 36882a8ee4..c8576e3c1b 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/state.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/state.go @@ -202,12 +202,6 @@ func (ai *AllocationInfo) CheckMainContainer() bool { return ai.ContainerType == pluginapi.ContainerType_MAIN.String() } -// CheckNumaBinding returns true if the AllocationInfo is for pod with numa-binding enhancement -func (ai *AllocationInfo) CheckNumaBinding() bool { - return ai.Annotations[consts.PodAnnotationMemoryEnhancementNumaBinding] == - consts.PodAnnotationMemoryEnhancementNumaBindingEnable -} - // GetAllocationResultNUMASet returns numaSet parsed from TopologyAwareAssignments func (ai *AllocationInfo) GetAllocationResultNUMASet() machine.CPUSet { if ai == nil { @@ -255,26 +249,6 @@ func (ai *AllocationInfo) GetPodAggregatedRequest() (float64, bool) { return float64(resourceList.Cpu().MilliValue()) / 1000, true } -func CheckAllocationInfoTopologyAwareAssignments(ai1, ai2 *AllocationInfo) bool { - return checkCPUSetMap(ai1.TopologyAwareAssignments, ai2.TopologyAwareAssignments) -} - -func CheckAllocationInfoOriginTopologyAwareAssignments(ai1, ai2 *AllocationInfo) bool { - return checkCPUSetMap(ai1.OriginalTopologyAwareAssignments, ai2.OriginalTopologyAwareAssignments) -} - -func checkCPUSetMap(map1, map2 map[int]machine.CPUSet) bool { - if len(map1) != len(map2) { - return false - } - for numaNode, cset := range map1 { - if !map2[numaNode].Equals(cset) { - return false - } - } - return true -} - // CheckDedicated returns true if the AllocationInfo is for pod with dedicated-qos func CheckDedicated(ai *AllocationInfo) bool { if ai == nil { diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/util.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/util.go index 6112163923..06cb1bd55e 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/util.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/state/util.go @@ -463,3 +463,23 @@ func GetSharedNUMABindingTargetNuma(allocationInfo *AllocationInfo) (int, error) return targetNUMAID, nil } + +func CheckAllocationInfoTopologyAwareAssignments(ai1, ai2 *AllocationInfo) bool { + return checkCPUSetMap(ai1.TopologyAwareAssignments, ai2.TopologyAwareAssignments) +} + +func CheckAllocationInfoOriginTopologyAwareAssignments(ai1, ai2 *AllocationInfo) bool { + return checkCPUSetMap(ai1.OriginalTopologyAwareAssignments, ai2.OriginalTopologyAwareAssignments) +} + +func checkCPUSetMap(map1, map2 map[int]machine.CPUSet) bool { + if len(map1) != len(map2) { + return false + } + for numaNode, cset := range map1 { + if !map2[numaNode].Equals(cset) { + return false + } + } + return true +} diff --git a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/vpa_test.go b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/vpa_test.go index ae958344d3..a866e26064 100644 --- a/pkg/agent/qrm-plugins/cpu/dynamicpolicy/vpa_test.go +++ b/pkg/agent/qrm-plugins/cpu/dynamicpolicy/vpa_test.go @@ -48,7 +48,7 @@ func TestSNBVPA(t *testing.T) { dynamicPolicy, err := getTestDynamicPolicyWithInitialization(cpuTopology, tmpDir) as.Nil(err) - dynamicPolicy.podAnnotationKeptKeys = []string{consts.PodAnnotationVPAResizingKey} + dynamicPolicy.podAnnotationKeptKeys = []string{consts.PodAnnotationInplaceUpdateResizingKey} testName := "test" @@ -132,9 +132,9 @@ func TestSNBVPA(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", }, } @@ -157,9 +157,9 @@ func TestSNBVPA(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", }, } @@ -183,9 +183,9 @@ func TestSNBVPA(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", }, Hint: resizeHints1[0], } @@ -223,7 +223,7 @@ func TestSNBVPAWithSidecar(t *testing.T) { as.Nil(err) dynamicPolicy.podAnnotationKeptKeys = []string{ - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } @@ -404,10 +404,10 @@ func TestSNBVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"4\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"4\"}", }, } @@ -430,10 +430,10 @@ func TestSNBVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"4\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"4\"}", }, Hint: resizeMainContainerHints[0], } @@ -490,10 +490,10 @@ func TestSNBVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", }, } @@ -515,10 +515,10 @@ func TestSNBVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", }, } _, err = dynamicPolicy.Allocate(context.Background(), resizeSidecarContainerReq) @@ -539,10 +539,10 @@ func TestSNBVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", }, } resizeMainContainerResp, err = dynamicPolicy.GetTopologyHints(context.Background(), resizeMainContainerReq) @@ -563,10 +563,10 @@ func TestSNBVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", }, Hint: resizeMainContainerResp.ResourceHints[string(v1.ResourceCPU)].Hints[0], } @@ -634,7 +634,7 @@ func TestNormalShareVPA(t *testing.T) { dynamicPolicy, err := getTestDynamicPolicyWithInitialization(cpuTopology, tmpDir) as.Nil(err) - dynamicPolicy.podAnnotationKeptKeys = []string{consts.PodAnnotationMemoryEnhancementNumaBinding, consts.PodAnnotationVPAResizingKey} + dynamicPolicy.podAnnotationKeptKeys = []string{consts.PodAnnotationMemoryEnhancementNumaBinding, consts.PodAnnotationInplaceUpdateResizingKey} dynamicPolicy.transitionPeriod = 10 * time.Millisecond testName := "test" @@ -702,8 +702,8 @@ func TestNormalShareVPA(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", }, } @@ -725,8 +725,8 @@ func TestNormalShareVPA(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", }, } @@ -779,7 +779,7 @@ func TestNormalShareVPAWithSidecar(t *testing.T) { dynamicPolicy.podAnnotationKeptKeys = []string{ consts.PodAnnotationMemoryEnhancementNumaBinding, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } @@ -914,9 +914,9 @@ func TestNormalShareVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"4\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"4\"}", }, } @@ -982,9 +982,9 @@ func TestNormalShareVPAWithSidecar(t *testing.T) { consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationAggregatedRequestsKey: "{\"cpu\":\"5\"}", }, } diff --git a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy.go b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy.go index 463d953916..59d01e6093 100644 --- a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy.go +++ b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy.go @@ -510,7 +510,7 @@ func (p *DynamicPolicy) GetTopologyHints(ctx context.Context, return nil, fmt.Errorf("getReqQuantityFromResourceReq failed with error: %v", err) } - general.InfoS("GetTopologyHints is called", + general.InfoS("called", "podNamespace", req.PodNamespace, "podName", req.PodName, "containerName", req.ContainerName, @@ -805,7 +805,7 @@ func (p *DynamicPolicy) Allocate(ctx context.Context, return nil, fmt.Errorf("getReqQuantityFromResourceReq failed with error: %v", err) } - general.InfoS("Allocate is called", + general.InfoS("called", "podNamespace", req.PodNamespace, "podName", req.PodName, "containerName", req.ContainerName, @@ -886,7 +886,7 @@ func (p *DynamicPolicy) Allocate(ctx context.Context, }() allocationInfo := p.state.GetAllocationInfo(v1.ResourceMemory, req.PodUid, req.ContainerName) - if allocationInfo != nil && allocationInfo.AggregatedQuantity >= uint64(reqInt) && !util.PodIsInVPAResizing(req) { + if allocationInfo != nil && allocationInfo.AggregatedQuantity >= uint64(reqInt) && !util.PodInplaceUpdateResizing(req) { general.InfoS("already allocated and meet requirement", "podNamespace", req.PodNamespace, "podName", req.PodName, @@ -997,13 +997,14 @@ func (p *DynamicPolicy) getContainerRequestedMemoryBytes(allocationInfo *state.A return allocationInfo.AggregatedQuantity } - // optimize this logic someday: + // TODO optimize this logic someday: // only for refresh cpu request for old pod with cpu ceil and old VPA pods. + // we can remove refresh logic after upgrade all kubelet and qrm. if allocationInfo.QoSLevel == apiconsts.PodAnnotationQoSLevelSharedCores { // if there is these two annotations in memory state, it is a new pod, // we don't need to check the pod request from podWatcher if allocationInfo.Annotations[apiconsts.PodAnnotationAggregatedRequestsKey] != "" || - allocationInfo.Annotations[apiconsts.PodAnnotationVPAResizingKey] != "" { + allocationInfo.Annotations[apiconsts.PodAnnotationInplaceUpdateResizingKey] != "" { return allocationInfo.AggregatedQuantity } @@ -1101,7 +1102,7 @@ func (p *DynamicPolicy) hasLastLevelEnhancementKey(lastLevelEnhancementKey strin } func (p *DynamicPolicy) checkNormalShareCoresResource(req *pluginapi.ResourceRequest) (bool, error) { - reqInt, _, err := util.GetQuantityFromResourceReq(req) + reqInt, _, err := util.GetPodAggregatedRequestResource(req) if err != nil { return false, fmt.Errorf("GetQuantityFromResourceReq failed with error: %v", err) } @@ -1109,9 +1110,9 @@ func (p *DynamicPolicy) checkNormalShareCoresResource(req *pluginapi.ResourceReq shareCoresAllocated := uint64(reqInt) podEntries := p.state.GetPodResourceEntries()[v1.ResourceMemory] for podUid, containerEntries := range podEntries { - for containerName, containerAllocation := range containerEntries { - // skip the current container - if podUid == req.PodUid && containerName == req.ContainerName { + for _, containerAllocation := range containerEntries { + // skip the current pod + if podUid == req.PodUid { continue } // shareCoresAllocated should involve both main and sidecar containers diff --git a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_allocation_handlers.go b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_allocation_handlers.go index 42c35ec0d7..b1d80fe64c 100644 --- a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_allocation_handlers.go +++ b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_allocation_handlers.go @@ -56,7 +56,7 @@ func (p *DynamicPolicy) reclaimedCoresAllocationHandler(ctx context.Context, return nil, fmt.Errorf("reclaimedCoresAllocationHandler got nil request") } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to memory VPA resize, but not support reclaimed cores", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("not support VPA resize for reclaiemd cores") @@ -76,7 +76,7 @@ func (p *DynamicPolicy) dedicatedCoresAllocationHandler(ctx context.Context, return nil, fmt.Errorf("dedicatedCoresAllocationHandler got nil req") } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to memory VPA resize, but not support dedicated cores", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("not support VPA resize for didecated cores") @@ -112,7 +112,7 @@ func (p *DynamicPolicy) numaBindingAllocationHandler(ctx context.Context, allocationInfo := p.state.GetAllocationInfo(v1.ResourceMemory, req.PodUid, req.ContainerName) if allocationInfo != nil { - if allocationInfo.AggregatedQuantity >= uint64(podAggregatedRequest) && !util.PodIsInVPAResizing(req) { + if allocationInfo.AggregatedQuantity >= uint64(podAggregatedRequest) && !util.PodInplaceUpdateResizing(req) { general.InfoS("already allocated and meet requirement", "podNamespace", req.PodNamespace, "podName", req.PodName, @@ -134,31 +134,12 @@ func (p *DynamicPolicy) numaBindingAllocationHandler(ctx context.Context, "containerName", req.ContainerName, "memoryReq(bytes)", podAggregatedRequest, "currentResult(bytes)", allocationInfo.AggregatedQuantity) - delete(podEntries, req.PodUid) - var stateErr error - memoryState, stateErr = state.GenerateMemoryStateFromPodEntries(p.state.GetMachineInfo(), podEntries, p.state.GetReservedMemory()) - if stateErr != nil { - general.ErrorS(stateErr, "generateMemoryMachineStateByPodEntries failed", - "podNamespace", req.PodNamespace, - "podName", req.PodName, - "containerName", req.ContainerName, - "memoryReq(bytes)", podAggregatedRequest, - "currentResult(bytes)", allocationInfo.AggregatedQuantity) - return nil, fmt.Errorf("generateMemoryMachineStateByPodEntries failed with error: %v", stateErr) - } - } else if util.PodIsInVPAResizing(req) { - general.Errorf("pod %s/%s, container: %s request to memory VPA, but no origin allocation info", - req.PodNamespace, req.PodName, req.ContainerName) - return nil, fmt.Errorf("no origin allocation info") - } - - if util.PodIsInVPAResizing(req) { - // remove the main container of this pod (the main container involve the whole pod requests) + // remove the main container of this pod (the main container involve the whole pod requests), and the + // sidecar container request in state is zero. containerEntries := podEntries[req.PodUid] delete(containerEntries, req.ContainerName) - // regenerate memory state (without the current pod) var stateErr error memoryState, stateErr = state.GenerateMemoryStateFromPodEntries(p.state.GetMachineInfo(), podEntries, p.state.GetReservedMemory()) if stateErr != nil { @@ -170,6 +151,10 @@ func (p *DynamicPolicy) numaBindingAllocationHandler(ctx context.Context, "currentResult(bytes)", allocationInfo.AggregatedQuantity) return nil, fmt.Errorf("generateMemoryMachineStateByPodEntries failed with error: %v", stateErr) } + } else if util.PodInplaceUpdateResizing(req) { + general.Errorf("pod %s/%s, container: %s request to memory VPA, but no origin allocation info", + req.PodNamespace, req.PodName, req.ContainerName) + return nil, fmt.Errorf("no origin allocation info") } // call calculateMemoryAllocation to update memoryState in-place, @@ -477,7 +462,7 @@ func (p *DynamicPolicy) adjustAllocationEntries() error { } } - // optimize this logic someday: + // TODO: optimize this logic someday: // only for refresh memory request for old VPA pods. for podUID, containerEntries := range podEntries { for containerName, allocationInfo := range containerEntries { 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 26488f8a2e..29273c30a9 100644 --- a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_hint_handlers.go +++ b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_hint_handlers.go @@ -44,32 +44,23 @@ func (p *DynamicPolicy) sharedCoresHintHandler(ctx context.Context, return p.numaBindingHintHandler(ctx, req) } - ok, err := p.checkNormalShareCoresResource(req) - if err != nil { - general.Errorf("failed to check share cores resource: %q", err) - return nil, fmt.Errorf("failed to check share cores resource: %q", err) - } + // TODO: support sidecar follow main container for normal share cores in future + if req.ContainerType == pluginapi.ContainerType_MAIN { + ok, err := p.checkNormalShareCoresResource(req) + if err != nil { + general.Errorf("failed to check share cores resource: %q", err) + return nil, fmt.Errorf("failed to check share cores resource: %q", err) + } - if !ok { - _ = p.emitter.StoreInt64(util.MetricNameShareCoresNoEnoughResourceFailed, 1, metrics.MetricTypeNameCount, []metrics.MetricTag{ - { - Key: "resource", - Val: "memory", - }, - { - Key: "userPodNs", - Val: req.PodNamespace, - }, - { - Key: "userPodName", - Val: req.PodName, - }, - { - Key: "userContainerName", - Val: req.ContainerName, - }, - }...) - return nil, fmt.Errorf("no enough memory resource") + if !ok { + _ = p.emitter.StoreInt64(util.MetricNameShareCoresNoEnoughResourceFailed, 1, metrics.MetricTypeNameCount, metrics.ConvertMapToTags(map[string]string{ + "resource": v1.ResourceMemory.String(), + "podNamespace": req.PodNamespace, + "podName": req.PodName, + "containerName": req.ContainerName, + })...) + return nil, fmt.Errorf("no enough memory resource") + } } return util.PackResourceHintsResponse(req, string(v1.ResourceMemory), @@ -81,7 +72,7 @@ func (p *DynamicPolicy) sharedCoresHintHandler(ctx context.Context, func (p *DynamicPolicy) reclaimedCoresHintHandler(ctx context.Context, req *pluginapi.ResourceRequest, ) (*pluginapi.ResourceHintsResponse, error) { - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to memory VPA resize, but not support reclaimed cores", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("not support VPA resize for reclaimed cores") @@ -96,7 +87,7 @@ func (p *DynamicPolicy) dedicatedCoresHintHandler(ctx context.Context, return nil, fmt.Errorf("dedicatedCoresHintHandler got nil req") } - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to memory VPA resize, but not support dedicated cores", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("not support VPA resize for didecated cores") @@ -137,10 +128,13 @@ func (p *DynamicPolicy) numaBindingHintHandler(_ context.Context, req.PodNamespace, req.PodName, req.ContainerName, allocationInfo.NumaAllocationResult.Size()) return nil, fmt.Errorf("invalid numa set size") } - hints = regenerateHints(uint64(podAggregatedRequest), allocationInfo, util.PodIsInVPAResizing(req)) + hints = regenerateHints(uint64(podAggregatedRequest), allocationInfo, util.PodInplaceUpdateResizing(req)) - // regenerateHints failed, and we need to clear container record and re-calculate. - if hints == nil { + // clear the current container and regenerate machine state in follow cases: + // 1. regenerateHints failed. + // 2. the container is inplace update resizing. + // hints it as a new container + if hints == nil || util.PodInplaceUpdateResizing(req) { var err error resourcesMachineState, err = p.clearContainerAndRegenerateMachineState(req) if err != nil { @@ -149,7 +143,7 @@ func (p *DynamicPolicy) numaBindingHintHandler(_ context.Context, return nil, fmt.Errorf("GenerateMachineStateFromPodEntries failed with error: %v", err) } } - } else if util.PodIsInVPAResizing(req) { + } else if util.PodInplaceUpdateResizing(req) { general.Errorf("pod: %s/%s, container: %s request to VPA resize, but no origin allocation info", req.PodNamespace, req.PodName, req.ContainerName) return nil, fmt.Errorf("no origin allocation info") @@ -169,7 +163,7 @@ func (p *DynamicPolicy) numaBindingHintHandler(_ context.Context, } // check or regenerate hints for VPA mode - if util.PodIsInVPAResizing(req) { + if util.PodInplaceUpdateResizing(req) { if allocationInfo.NumaAllocationResult.Size() != 1 { general.Errorf("pod: %s/%s, container: %s is snb, but its numa size is %d", req.PodNamespace, req.PodName, req.ContainerName, allocationInfo.NumaAllocationResult.Size()) @@ -185,7 +179,7 @@ func (p *DynamicPolicy) numaBindingHintHandler(_ context.Context, general.Infof("pod: %s/%s, main container: %s request to memory VPA resize (%d->%d)", req.PodNamespace, req.PodName, req.ContainerName, originPodAggregatedRequest, podAggregatedRequest) - if originPodAggregatedRequest < uint64(podAggregatedRequest) && uint64(podAggregatedRequest)-originPodAggregatedRequest > nodeMemoryState.Free { // no left resource to scale out + if uint64(podAggregatedRequest) > nodeMemoryState.Free { // no left resource to scale out // TODO maybe support snb NUMA migrate VPA later isVpaMigratable := false if isVpaMigratable { @@ -193,19 +187,12 @@ func (p *DynamicPolicy) numaBindingHintHandler(_ context.Context, "to scale out in current numa (resize request extra: %d, free: %d), migrate numa", req.PodNamespace, req.PodName, req.ContainerName, originPodAggregatedRequest, podAggregatedRequest, uint64(podAggregatedRequest)-originPodAggregatedRequest, nodeMemoryState.Free) - // we just need to clear the main container of the pod, because the main container aggregated quantity - // involve the whole pod (only for memory admit). - resourcesMachineState, err = p.clearContainerAndRegenerateMachineState(req) - if err != nil { - general.Errorf("pod: %s/%s, container: %s clearContainerAndRegenerateMachineState failed in VPA mode with error: %v", - req.PodNamespace, req.PodName, req.ContainerName, err) - return nil, err - } - var calculateErr error // recalculate hints for the whole pod hints, calculateErr = p.calculateHints(uint64(podAggregatedRequest), resourcesMachineState, req.Annotations) if calculateErr != nil { + general.Errorf("failed to calculate hints for pod: %s/%s, container: %s, error: %v", + req.PodNamespace, req.PodName, req.ContainerName, calculateErr) return nil, fmt.Errorf("calculateHints failed with error: %v", calculateErr) } } else { @@ -374,11 +361,11 @@ func (p *DynamicPolicy) calculateHints(reqInt uint64, resourcesMachineState stat // regenerateHints regenerates hints for container that'd already been allocated memory, // and regenerateHints will assemble hints based on already-existed AllocationInfo, // without any calculation logics at all -func regenerateHints(reqInt uint64, allocationInfo *state.AllocationInfo, podIsInVpaResizing bool) map[string]*pluginapi.ListOfTopologyHints { +func regenerateHints(reqInt uint64, allocationInfo *state.AllocationInfo, podInplaceUpdateResizing bool) map[string]*pluginapi.ListOfTopologyHints { hints := map[string]*pluginapi.ListOfTopologyHints{} allocatedInt := allocationInfo.AggregatedQuantity - if allocatedInt < reqInt && !podIsInVpaResizing { + if allocatedInt < reqInt && !podInplaceUpdateResizing { general.ErrorS(nil, "memory's already allocated with smaller quantity than requested", "podUID", allocationInfo.PodUid, "containerName", allocationInfo.ContainerName, "requestedResource", reqInt, "allocatedSize", allocatedInt) diff --git a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_test.go b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_test.go index 2e705cc5c5..0bf54d0698 100644 --- a/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_test.go +++ b/pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_test.go @@ -3787,7 +3787,7 @@ func TestSNBMemoryAdmitWithSidecarReallocate(t *testing.T) { as.Nil(err) dynamicPolicy.podAnnotationKeptKeys = []string{ consts.PodAnnotationMemoryEnhancementNumaBinding, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } diff --git a/pkg/agent/qrm-plugins/memory/dynamicpolicy/vpa_test.go b/pkg/agent/qrm-plugins/memory/dynamicpolicy/vpa_test.go index ca79cb6aab..c0a1ddeac3 100644 --- a/pkg/agent/qrm-plugins/memory/dynamicpolicy/vpa_test.go +++ b/pkg/agent/qrm-plugins/memory/dynamicpolicy/vpa_test.go @@ -49,7 +49,7 @@ func TestSNBMemoryVPA(t *testing.T) { dynamicPolicy, err := getTestDynamicPolicyWithInitialization(cpuTopology, machineInfo, tmpDir) as.Nil(err) dynamicPolicy.podAnnotationKeptKeys = []string{ - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } @@ -126,9 +126,9 @@ func TestSNBMemoryVPA(t *testing.T) { string(v1.ResourceMemory): 4294967296, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -154,9 +154,9 @@ func TestSNBMemoryVPA(t *testing.T) { string(v1.ResourceMemory): 4294967296, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -188,9 +188,9 @@ func TestSNBMemoryVPA(t *testing.T) { string(v1.ResourceMemory): 8 * 1024 * 1024 * 1024, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -219,7 +219,7 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { as.Nil(err) dynamicPolicy.podAnnotationKeptKeys = []string{ consts.PodAnnotationMemoryEnhancementNumaBinding, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } @@ -390,10 +390,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 4294967296, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 6442450944}`, // sidecar 2G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 6442450944}`, // sidecar 2G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -418,10 +418,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 4294967296, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 6442450944}`, // sidecar 2G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 6442450944}`, // sidecar 2G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -457,10 +457,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 3 * 1024 * 1024 * 1024, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 3G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 3G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -485,10 +485,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 3 * 1024 * 1024 * 1024, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 3G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 3G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -510,10 +510,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 4294967296, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 2G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 2G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -538,10 +538,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 4294967296, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 2G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 7516192768}`, // sidecar 2G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -577,10 +577,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 32 * 1024 * 1024 * 1024, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 37580963840}`, // sidecar 2G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 37580963840}`, // sidecar 2G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -602,10 +602,10 @@ func TestSNBMemoryVPAWithSidecar(t *testing.T) { string(v1.ResourceMemory): 32 * 1024 * 1024 * 1024, }, Annotations: map[string]string{ - consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, - consts.PodAnnotationVPAResizingKey: "true", - consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, - consts.PodAnnotationAggregatedRequestsKey: `{"memory": 37580963840}`, // sidecar 3G + main 4G + consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, + consts.PodAnnotationInplaceUpdateResizingKey: "true", + consts.PodAnnotationMemoryEnhancementKey: `{"numa_binding": "true", "numa_exclusive": "false"}`, + consts.PodAnnotationAggregatedRequestsKey: `{"memory": 37580963840}`, // sidecar 3G + main 4G }, Labels: map[string]string{ consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores, @@ -636,7 +636,7 @@ func TestNormalShareMemoryVPA(t *testing.T) { as.Nil(err) dynamicPolicy.podAnnotationKeptKeys = []string{ consts.PodAnnotationMemoryEnhancementNumaBinding, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } @@ -745,7 +745,7 @@ func TestNormalShareMemoryVPAWithSidecar(t *testing.T) { as.Nil(err) dynamicPolicy.podAnnotationKeptKeys = []string{ consts.PodAnnotationMemoryEnhancementNumaBinding, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, consts.PodAnnotationAggregatedRequestsKey, } diff --git a/pkg/agent/qrm-plugins/util/util.go b/pkg/agent/qrm-plugins/util/util.go index d89fef228b..d7bd1348e0 100644 --- a/pkg/agent/qrm-plugins/util/util.go +++ b/pkg/agent/qrm-plugins/util/util.go @@ -327,8 +327,8 @@ func GetAsyncWorkNameByPrefix(prefix, topic string) string { return strings.Join([]string{prefix, topic}, asyncworker.WorkNameSeperator) } -func PodIsInVPAResizing(req *pluginapi.ResourceRequest) bool { - return req.Annotations != nil && req.Annotations[apiconsts.PodAnnotationVPAResizingKey] == "true" +func PodInplaceUpdateResizing(req *pluginapi.ResourceRequest) bool { + return req.Annotations != nil && req.Annotations[apiconsts.PodAnnotationInplaceUpdateResizingKey] == "true" } func GetPodAggregatedRequestResource(req *pluginapi.ResourceRequest) (int, float64, error) { diff --git a/pkg/config/agent/qrm/qrm_base.go b/pkg/config/agent/qrm/qrm_base.go index ba17907538..14387bc334 100644 --- a/pkg/config/agent/qrm/qrm_base.go +++ b/pkg/config/agent/qrm/qrm_base.go @@ -41,7 +41,7 @@ func NewGenericQRMPluginConfiguration() *GenericQRMPluginConfiguration { return &GenericQRMPluginConfiguration{ PodAnnotationKeptKeys: []string{ consts.PodAnnotationAggregatedRequestsKey, - consts.PodAnnotationVPAResizingKey, + consts.PodAnnotationInplaceUpdateResizingKey, }, PodLabelKeptKeys: []string{}, }