Skip to content

Commit c978771

Browse files
committed
set allocatable replicas for unhealthy cluster to zero when scale up.
Signed-off-by: LivingCcj <[email protected]>
1 parent f8c59e4 commit c978771

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/apis/cluster/v1alpha1/cluster_helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ func (c *Cluster) APIEnablement(gvk schema.GroupVersionKind) APIEnablementStatus
6565

6666
return APIUnknown
6767
}
68+
69+
func (c *Cluster) IsClusterReady() bool {
70+
return meta.IsStatusConditionPresentAndEqual(c.Status.Conditions, ClusterConditionReady, metav1.ConditionTrue)
71+
}

pkg/scheduler/core/division_algorithm.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core
1818

1919
import (
2020
"fmt"
21+
"k8s.io/klog/v2"
2122
"sort"
2223

2324
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
@@ -122,6 +123,11 @@ func dynamicScaleUp(state *assignState) ([]workv1alpha2.TargetCluster, error) {
122123
state.buildAvailableClusters(func(clusters []spreadconstraint.ClusterDetailInfo, _ *workv1alpha2.ResourceBindingSpec) []workv1alpha2.TargetCluster {
123124
clusterAvailableReplicas := make([]workv1alpha2.TargetCluster, len(clusters))
124125
for i, cluster := range clusters {
126+
// set allocatable replicas for unhealthy cluster to zero when scale up.
127+
if !cluster.Cluster.IsClusterReady() {
128+
klog.Warningf("Cluster %s is not ready, skip it when scale up.", cluster.Name)
129+
cluster.AllocatableReplicas = 0
130+
}
125131
clusterAvailableReplicas[i] = workv1alpha2.TargetCluster{
126132
Name: cluster.Name,
127133
Replicas: cluster.AllocatableReplicas,

0 commit comments

Comments
 (0)