Multi-component workloads may be scheduled to clusters with insufficient resources
kind/bug
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!
-->
**What happened**:
When scheduling a multi-component workload (e.g., FlinkDeployment) to member clusters, the scheduler does not filter out clusters that lack sufficient resources. Even when the scheduler-estimator reports that a cluster cannot accommodate any component of the workload, the scheduler still selects that cluster.
***root cause***
https://github.com/karmada-io/karmada/blob/c7ac0f0f364e372ffd12949f07f262127e6d7c55/pkg/scheduler/core/common.go#L41
https://github.com/karmada-io/karmada/blob/c7ac0f0f364e372ffd12949f07f262127e6d7c55/pkg/scheduler/core/spreadconstraint/select_clusters_by_cluster.go#L74
`SelectBestClusters` uses `spec.Replicas` as `needReplicas` to check whether clusters have enough available resources. For multi-component workloads, `spec.Replicas` is `0` (replicas are tracked per-component in `spec.Components`). This makes the check `availableReplicas >= 0` trivially true, effectively bypassing the resource validation.
***Fix***
For multi-component workloads, `needReplicas` should be `1` instead of `0`. The semantics is: the cluster must be able to accommodate at least one complete set of the workload's components.
**What you expected to happen**:
Clusters with insufficient resources should be filtered out during the Select stage. When the estimator reports zero available components for a cluster, that cluster should not be selected.
**How to reproduce it (as minimally and precisely as possible)**:
1. Register a member cluster with limited resources.
2. Deploy a multi-component workload (e.g., FlinkDeployment) with a PropagationPolicy that targets the member cluster.
3. Ensure the member cluster does not have enough resources to run the workload's components.
4. Observe that the scheduler still selects the resource-insufficient cluster.
**Anything else we need to know?**:
**Environment**:
- Karmada version:
- kubectl-karmada or karmadactl version (the result of `kubectl-karmada version` or `karmadactl version`):
- Others:
1 条评论