Skip to content

Commit

Permalink
add pod constraint in general estimator
Browse files Browse the repository at this point in the history
Signed-off-by: Garrybest <[email protected]>
  • Loading branch information
Garrybest committed Sep 29, 2021
1 parent c4e2271 commit 363ba75
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/estimator/client/general.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package client

import (
"math"

corev1 "k8s.io/api/core/v1"

clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
Expand Down Expand Up @@ -33,13 +31,17 @@ func (ge *GeneralEstimator) MaxAvailableReplicas(clusters []*clusterv1alpha1.Clu
}

func (ge *GeneralEstimator) maxAvailableReplicas(cluster *clusterv1alpha1.Cluster, replicaRequirements *workv1alpha2.ReplicaRequirements) int32 {
var maximumReplicas int64 = math.MaxInt32
resourceSummary := cluster.Status.ResourceSummary

if resourceSummary == nil {
return 0
}

allowedPodNumber := resourceSummary.Allocatable.Pods().Value() - resourceSummary.Allocated.Pods().Value() - resourceSummary.Allocating.Pods().Value()
if allowedPodNumber <= 0 {
return 0
}
maximumReplicas := allowedPodNumber

for key, value := range replicaRequirements.ResourceRequest {
requestedQuantity := value.Value()
if requestedQuantity <= 0 {
Expand Down

0 comments on commit 363ba75

Please sign in to comment.