karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.1k stars 799 forks source link

Scheduler: optimize scheduler framework. #3318

Open chaunceyjiang opened 1 year ago

chaunceyjiang commented 1 year ago

What would you like to be added:

Optimize scheduler framework.

Why is this needed:

When I wanted to add a scheduling plugin to the scheduler, I found it difficult to do it under the current scheduling framework. The current scheduling process lacks scheduling steps, such as: preFilter, postFilter, preScore, etc., and also lacks a cycle state, which is used to share data in different plug-ins.

The scheduler should only use the score to select the cluster to be scheduled, no other additional reasons are required.

So there are two goals for this optimization.

  1. Increase the extension point of the scheduler
  2. Convert all the information needed by the scheduler into scores.

Now:

image

Disadvantages: There are too few scheduler extension points, and data cannot be shared between plug-ins.

After:

image

Data can be shared between different plugins via CycleState.

chaunceyjiang commented 1 year ago

/cc @Garrybest @jwcesign @RainbowMango @whitewindmills

Please take a look.

XiShanYongYe-Chang commented 1 year ago

You can add an agenda to the community meeting to introduce it in detail.

Poor12 commented 1 year ago

I have a question, do we really need prefilter, postFilter and postScore now? Is there a definite plugin to add in this step? If we currently do not have a clear built-in plug-in at this step, how can we judge that users have the need for this extension?For example, a typical postfilter implementation is preemption, but Karmada does not involve now. We can discuss it in next meeting.

chaunceyjiang commented 1 year ago

Yes, that's a very good question. I'm not able to fully answer your question at the moment. As described in the issue Convert all the information needed by the scheduler into scores, I just wanted to convert AvailableReplicas into scores. However, as you can see in the PR, its implementation is very poor due to insufficient extensibility of the current scheduling framework.

Hopefully we will have a clear conclusion in Karmada next meeting.

Garrybest commented 1 year ago

I think Prefilter is necessary so far, we need this extension point to get all available replicas. Other extension could be added in the future if it is necessary.

chaunceyjiang commented 1 year ago

For the current implementation of the assignment algorithm based on weight, the weight information in Placement is directly read. I have an idea 😂, is it possible to convert the weights into scores and assign Replicas according to the weight of the scores?

Garrybest commented 1 year ago

I have thought this before. Firstly by Filter plugin, we caculate the upper boundary replicas of every member cluster. And then Score plugin help us caculate the weight of all member clusters. But I'm not sure if this method could meet the requirement of all scenarios.

Poor12 commented 1 year ago

I find that the scheduler uses cluster resources in the three steps of score, selectClusters and assignReplicas. These steps are not dependent on timing and can use the same data. I wonder if we can put cluster resources into the snapshot. We use the same data in all steps of one scheduling.

// Snapshot is a snapshot of cache ClusterInfo. The scheduler takes a
// snapshot at the beginning of each scheduling cycle and uses it for its operations in that cycle.
type Snapshot struct {
    // clusterInfoList is the list of nodes as ordered in the cache's nodeTree.
    clusterInfoList []*framework.ClusterInfo
}
chaunceyjiang commented 1 year ago

We use the same data in all steps of one scheduling.

This is the core idea of my PR #3299.

Garrybest commented 1 year ago

I'm trying to design a new scheduelr framework. A little bit difficult. I will show you ASAP.

jwcesign commented 1 year ago

Is it possible to extract this framework as a utility library? Doing so would enable other areas to utilize the scheduling logic in the future, such as FederatedHPA.

RainbowMango commented 1 year ago

I'm trying to design a new scheduelr framework. A little bit difficult. I will show you ASAP.

👍

chaosi-zju commented 8 months ago

@chaunceyjiang @Garrybest Hello, is this new scheduler framework task is on going? If it is temporarily interrupted, I am very interested in resuming and following up on this task. It sounds like a very challenging and interesting task and I am willing to have a try~

Garrybest commented 8 months ago

Hi @chaosi-zju, FYI, I have written an implementation here😄.