Repository navigation
[core][scheduler] Honor node label constraints when the local node is preferred - #68610
RocMarshal wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that the local node preference shortcut in the cluster resource scheduler is bypassed when a node label scheduling strategy is present, and adds a corresponding unit test. The feedback suggests further expanding this bypass logic to also exclude other non-default scheduling strategies, such as NodeAffinitySchedulingStrategy and SpreadSchedulingStrategy, to prevent incorrect scheduling that violates affinity constraints or defeats spread behavior.
| const bool prefer_local_node = | ||
| preferred_node_id == local_node_id_.Binary() && | ||
| !scheduling_strategy.has_node_label_scheduling_strategy(); |
There was a problem hiding this comment.
The local preference shortcut bypasses the full scheduling policy to immediately schedule the lease on the local node if resources are available. While this is a great optimization for the default/hybrid policy, it should also be skipped for other non-default scheduling strategies like NodeAffinitySchedulingStrategy (especially with hard affinity constraints) and SpreadSchedulingStrategy.\n\nIf a lease has a hard node affinity to a remote node, but the local node is preferred (e.g., as a fallback or default preferred node), the shortcut would incorrectly schedule it on the local node, violating the affinity constraint. Similarly, for spread scheduling, always scheduling locally when the local node is preferred defeats the spread behavior.\n\nWe should expand prefer_local_node to exclude these strategies as well.
const bool prefer_local_node =\n preferred_node_id == local_node_id_.Binary() &&\n !scheduling_strategy.has_node_label_scheduling_strategy() &&\n !scheduling_strategy.has_node_affinity_scheduling_strategy() &&\n scheduling_strategy.scheduling_strategy_case() !=\n rpc::SchedulingStrategy::SchedulingStrategyCase::kSpreadSchedulingStrategy;… preferred Signed-off-by: Yuepeng Pan <[email protected]>
1b1fe83 to
b4d9f4a
Compare
Description
When the local node is preferred, the lease scheduler can select it without
evaluating
NodeLabelSchedulingStrategy. For example, a lease requiringregion=us-westcan be assigned to the localus-eastnode.Skip both local preference shortcuts for leases using this strategy: immediate
placement on an available local node and fallback to waiting on the local node.
The regression test covers an available local node and the case where both nodes
are busy, with only the remote node matching the hard label in both cases.
Related issues
No issues.
Additional information
N.A