@@ -11,7 +11,6 @@ import (
11
11
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
12
12
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
13
13
"github.com/karmada-io/karmada/pkg/scheduler/cache"
14
- "github.com/karmada-io/karmada/pkg/scheduler/core/spreadconstraint"
15
14
"github.com/karmada-io/karmada/pkg/scheduler/framework"
16
15
"github.com/karmada-io/karmada/pkg/scheduler/framework/runtime"
17
16
"github.com/karmada-io/karmada/pkg/scheduler/metrics"
@@ -159,44 +158,12 @@ func (g *genericScheduler) prioritizeClusters(
159
158
160
159
func (g * genericScheduler ) selectClusters (clustersScore framework.ClusterScoreList ,
161
160
placement * policyv1alpha1.Placement , spec * workv1alpha2.ResourceBindingSpec ) ([]* clusterv1alpha1.Cluster , error ) {
162
- startTime := time .Now ()
163
- defer metrics .ScheduleStep (metrics .ScheduleStepSelect , startTime )
164
161
165
- groupClustersInfo := spreadconstraint .GroupClustersWithScore (clustersScore , placement , spec , calAvailableReplicas )
166
- return spreadconstraint .SelectBestClusters (placement , groupClustersInfo , spec .Replicas )
162
+ return SelectClusters (clustersScore , placement , spec )
167
163
}
168
164
169
- func (g * genericScheduler ) assignReplicas (
170
- clusters []* clusterv1alpha1.Cluster ,
171
- placement * policyv1alpha1.Placement ,
172
- object * workv1alpha2.ResourceBindingSpec ,
173
- ) ([]workv1alpha2.TargetCluster , error ) {
174
- startTime := time .Now ()
175
- defer metrics .ScheduleStep (metrics .ScheduleStepAssignReplicas , startTime )
165
+ func (g * genericScheduler ) assignReplicas (clusters []* clusterv1alpha1.Cluster , placement * policyv1alpha1.Placement ,
166
+ object * workv1alpha2.ResourceBindingSpec ) ([]workv1alpha2.TargetCluster , error ) {
176
167
177
- if len (clusters ) == 0 {
178
- return nil , fmt .Errorf ("no clusters available to schedule" )
179
- }
180
-
181
- if object .Replicas > 0 {
182
- state := newAssignState (clusters , placement , object )
183
- assignFunc , ok := assignFuncMap [state .strategyType ]
184
- if ! ok {
185
- // should never happen at present
186
- return nil , fmt .Errorf ("unsupported replica scheduling strategy, replicaSchedulingType: %s, replicaDivisionPreference: %s, " +
187
- "please try another scheduling strategy" , placement .ReplicaSchedulingType (), placement .ReplicaScheduling .ReplicaDivisionPreference )
188
- }
189
- assignResults , err := assignFunc (state )
190
- if err != nil {
191
- return nil , err
192
- }
193
- return removeZeroReplicasCluster (assignResults ), nil
194
- }
195
-
196
- // If not workload, assign all clusters without considering replicas.
197
- targetClusters := make ([]workv1alpha2.TargetCluster , len (clusters ))
198
- for i , cluster := range clusters {
199
- targetClusters [i ] = workv1alpha2.TargetCluster {Name : cluster .Name }
200
- }
201
- return targetClusters , nil
168
+ return AssignReplicas (clusters , placement , object )
202
169
}
0 commit comments