Skip to content

Commit 006edc1

Browse files
authored
Merge pull request #785 from luomingmeng/dev/fix-sharedCoresWithNUMABindingHintHandler
fix(qrm): fix sharedCoresWithNUMABindingHintHandler when hints already existed
2 parents bf40e83 + 13dbb7d commit 006edc1

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_hint_handlers.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -718,44 +718,44 @@ func (p *DynamicPolicy) sharedCoresWithNUMABindingHintHandler(_ context.Context,
718718
req.PodNamespace, req.PodName, req.ContainerName, err)
719719
return nil, fmt.Errorf("GenerateMachineStateFromPodEntries failed with error: %v", err)
720720
}
721-
}
722721

723-
general.Infof("pod: %s/%s, container: %s, inplace update resize: %v", req.PodNamespace, req.PodName, req.ContainerName, util.PodInplaceUpdateResizing(req))
724-
numaSet := allocationInfo.GetAllocationResultNUMASet()
725-
if numaSet.Size() != 1 {
726-
general.Errorf("pod: %s/%s, container: %s is snb, but its numa set size is %d",
727-
req.PodNamespace, req.PodName, req.ContainerName, numaSet.Size())
728-
return nil, fmt.Errorf("snb port not support cross numa")
729-
}
730-
nodeID := numaSet.ToSliceInt()[0]
731-
availableCPUQuantity := machineState[nodeID].GetAvailableCPUQuantity(p.reservedCPUs)
722+
general.Infof("pod: %s/%s, container: %s, inplace update resize: %v", req.PodNamespace, req.PodName, req.ContainerName, util.PodInplaceUpdateResizing(req))
723+
numaSet := allocationInfo.GetAllocationResultNUMASet()
724+
if numaSet.Size() != 1 {
725+
general.Errorf("pod: %s/%s, container: %s is snb, but its numa set size is %d",
726+
req.PodNamespace, req.PodName, req.ContainerName, numaSet.Size())
727+
return nil, fmt.Errorf("snb port not support cross numa")
728+
}
729+
nodeID := numaSet.ToSliceInt()[0]
730+
availableCPUQuantity := machineState[nodeID].GetAvailableCPUQuantity(p.reservedCPUs)
732731

733-
general.Infof("pod: %s/%s, container: %s request cpu inplace update resize on numa %d (available: %.3f, request: %.3f)",
734-
req.PodNamespace, req.PodName, req.ContainerName, nodeID, availableCPUQuantity, request)
735-
if !cpuutil.CPUIsSufficient(request, availableCPUQuantity) { // no left resource to scale out
736-
general.Infof("pod: %s/%s, container: %s request cpu inplace update resize, but no enough resource for it in current NUMA, checking migratable",
737-
req.PodNamespace, req.PodName, req.ContainerName)
738-
// TODO move this var to config
739-
isInplaceUpdateResizeNumaMigration := false
740-
if isInplaceUpdateResizeNumaMigration {
741-
general.Infof("pod: %s/%s, container: %s request inplace update resize and no enough resource in current NUMA, try to migrate it to new NUMA",
732+
general.Infof("pod: %s/%s, container: %s request cpu inplace update resize on numa %d (available: %.3f, request: %.3f)",
733+
req.PodNamespace, req.PodName, req.ContainerName, nodeID, availableCPUQuantity, request)
734+
if !cpuutil.CPUIsSufficient(request, availableCPUQuantity) { // no left resource to scale out
735+
general.Infof("pod: %s/%s, container: %s request cpu inplace update resize, but no enough resource for it in current NUMA, checking migratable",
742736
req.PodNamespace, req.PodName, req.ContainerName)
743-
var calculateErr error
744-
hints, calculateErr = p.calculateHintsForNUMABindingSharedCores(request, podEntries, machineState, req)
745-
if calculateErr != nil {
746-
general.Errorf("pod: %s/%s, container: %s request inplace update resize and no enough resource in current NUMA, failed to migrate it to new NUMA",
737+
// TODO move this var to config
738+
isInplaceUpdateResizeNumaMigration := false
739+
if isInplaceUpdateResizeNumaMigration {
740+
general.Infof("pod: %s/%s, container: %s request inplace update resize and no enough resource in current NUMA, try to migrate it to new NUMA",
747741
req.PodNamespace, req.PodName, req.ContainerName)
748-
return nil, fmt.Errorf("calculateHintsForNUMABindingSharedCores failed in inplace update resize mode with error: %v", calculateErr)
742+
var calculateErr error
743+
hints, calculateErr = p.calculateHintsForNUMABindingSharedCores(request, podEntries, machineState, req)
744+
if calculateErr != nil {
745+
general.Errorf("pod: %s/%s, container: %s request inplace update resize and no enough resource in current NUMA, failed to migrate it to new NUMA",
746+
req.PodNamespace, req.PodName, req.ContainerName)
747+
return nil, fmt.Errorf("calculateHintsForNUMABindingSharedCores failed in inplace update resize mode with error: %v", calculateErr)
748+
}
749+
} else {
750+
general.Errorf("pod: %s/%s, container: %s request inplace update resize, but no enough resource for it in current NUMA",
751+
req.PodNamespace, req.PodName, req.ContainerName)
752+
return nil, errNoAvailableCPUHints
749753
}
750754
} else {
751-
general.Errorf("pod: %s/%s, container: %s request inplace update resize, but no enough resource for it in current NUMA",
755+
general.Infof("pod: %s/%s, container: %s request inplace update resize, there is enough resource for it in current NUMA",
752756
req.PodNamespace, req.PodName, req.ContainerName)
753-
return nil, errNoAvailableCPUHints
757+
hints = cpuutil.RegenerateHints(allocationInfo, false)
754758
}
755-
} else {
756-
general.Infof("pod: %s/%s, container: %s request inplace update resize, there is enough resource for it in current NUMA",
757-
req.PodNamespace, req.PodName, req.ContainerName)
758-
hints = cpuutil.RegenerateHints(allocationInfo, false)
759759
}
760760
} else {
761761
var calculateErr error

0 commit comments

Comments
 (0)