Merge pull request #2714 from Garrybest/pr_estimator

fix bugs of nodeMaxAvailableReplica
This commit is contained in:
karmada-bot 2022-11-02 09:34:25 +08:00 committed by GitHub
commit 7be4f865e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/karmada-io/karmada/pkg/estimator/pb"
nodeutil "github.com/karmada-io/karmada/pkg/estimator/server/nodes"
"github.com/karmada-io/karmada/pkg/util"
schedcache "github.com/karmada-io/karmada/pkg/util/lifted/scheduler/cache"
"github.com/karmada-io/karmada/pkg/util/lifted/scheduler/framework"
)
@ -72,8 +73,10 @@ func (es *AccurateSchedulerEstimatorServer) estimateReplicas(
func (es *AccurateSchedulerEstimatorServer) nodeMaxAvailableReplica(node *framework.NodeInfo, rl corev1.ResourceList) int32 {
rest := node.Allocatable.Clone().SubResource(node.Requested)
if rest.AllowedPodNumber > int64(len(node.Pods)) {
rest.AllowedPodNumber -= int64(len(node.Pods))
}
// The number of pods in a node is a kind of resource in node allocatable resources.
// However, total requested resources of all pods on this node, i.e. `node.Requested`,
// do not contain pod resources. So after subtraction, we should cope with allowed pod
// number manually which is the upper bound of this node available replicas.
rest.AllowedPodNumber = util.MaxInt64(rest.AllowedPodNumber-int64(len(node.Pods)), 0)
return int32(rest.MaxDivided(rl))
}