-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GenerateClustersInfo should take AvailableReplicas into account when sorting #5129
Comments
/assign |
cc @whitewindmills here to take a look. |
I agree with it. |
@whitewindmills Is this reserved for extensions? |
sure |
it is a small optimization, fell free to address this. |
I prefer this to be an optimization. 😀 |
Sounds good, I'll open a PR shortly.
In our case, we'd just like to spread out our applications across the clusters. At the moment the default behavior for the sort is to sort by cluster name if the score is the same - this leads us to pack a single cluster until there are not enough resources. |
What happened:
When scheduling, Karmada will select the clusters out of the list of candidates (ClusterDetailInfo) sorted by cluster.Score descending. This sorting is done by spreadconstraint#sortClusters, and called when running generateClustersInfo. Currently the sort only accounts for cluster.Score, but in edge cases where the score between clusters is the same, we should prefer scheduling on clusters with more availableReplicas. Instead, we just pick the first cluster our of the sorted list:
What you expected to happen:
Ideally, when creating the default list of ClusterInfo, we should additionally sort by availableReplicas. So in the above example, Karmada should select
Cluster-B
since the score is the same, but Cluster-B has more availableReplicas (20).How to reproduce it (as minimally and precisely as possible):
This is easily reproducible when clusters have the same ClusterAffinity / ClusterLocality scores. In that case, the clusters are only sorted by score rather than availableReplica.
Potential fixes:
I was able to address this by adding an additional compareFunction to the generateClusterInfo method:
Out of curiosity, do we see future cases for custom compareFunctions in sortClusters definition? This could also be fixed by sorting clusters by default using these rules:
Environment:
The text was updated successfully, but these errors were encountered: