Skip to content

Commit

Permalink
Merge pull request #283 from qclc/rsp-support-noschedule
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-lgy authored Nov 21, 2023
2 parents 6bfa139 + 3f69ebc commit ad527b5
Show file tree
Hide file tree
Showing 2 changed files with 484 additions and 15 deletions.
43 changes: 28 additions & 15 deletions pkg/controllers/scheduler/framework/plugins/rsp/rsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,6 @@ func (pl *ClusterCapacityWeight) ReplicaScheduling(
schedulingWeights = su.Weights
}

clusterPreferences := map[string]planner.ClusterPreferences{}
for _, cluster := range clusters {
pref := planner.ClusterPreferences{
Weight: schedulingWeights[cluster.Name],
MinReplicas: su.MinReplicas[cluster.Name],
MaxReplicas: nil,
}

if maxReplicas, exists := su.MaxReplicas[cluster.Name]; exists {
pref.MaxReplicas = pointer.Int64Ptr(maxReplicas)
}

clusterPreferences[cluster.Name] = pref
}

totalReplicas := int64(0)
if su.DesiredReplicas != nil {
totalReplicas = *su.DesiredReplicas
Expand All @@ -127,6 +112,34 @@ func (pl *ClusterCapacityWeight) ReplicaScheduling(
currentReplicas[cluster] = totalReplicas
}

clusterPreferences := map[string]planner.ClusterPreferences{}
for _, cluster := range clusters {
pref := planner.ClusterPreferences{
Weight: schedulingWeights[cluster.Name],
MinReplicas: su.MinReplicas[cluster.Name],
MaxReplicas: nil,
}

if maxReplicas, exists := su.MaxReplicas[cluster.Name]; exists {
pref.MaxReplicas = pointer.Int64(maxReplicas)
}

// if member cluster has untolerated NoSchedule taint, no new replicas will be scheduled to this cluster
if _, isUntolerated := framework.FindMatchingUntoleratedTaint(
cluster.Spec.Taints,
su.Tolerations,
func(t *corev1.Taint) bool {
return t.Effect == corev1.TaintEffectNoSchedule
},
); isUntolerated {
if pref.MaxReplicas == nil || currentReplicas[cluster.Name] < *pref.MaxReplicas {
pref.MaxReplicas = pointer.Int64(currentReplicas[cluster.Name])
}
}

clusterPreferences[cluster.Name] = pref
}

estimatedCapacity := map[string]int64{}
keepUnschedulableReplicas := false
if autoMigration := su.AutoMigration; autoMigration != nil {
Expand Down
Loading

0 comments on commit ad527b5

Please sign in to comment.