Skip to content
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

fix(scheduler): prevents scheduling new replicas to terminating clusters #263

Closed

Conversation

JackZxj
Copy link
Collaborator

@JackZxj JackZxj commented Nov 9, 2023

The current scheduler does not filter clusters being deleted because it may be necessary to retain resources in member clusters. However, this situation resulted in:

  1. One member cluster is stuck in deletion
  2. Workload is distributed using Divide mode
  3. The deleting cluster has a high weight after filter and score.

The scheduler may schedule new replicas to this terminating cluster. However the sync controller will not dispatch resources to the terminating clusters. This will cause the workload to fail to scale up in federation.

This PR ensures that the terminating cluster will not scale up by setting MaxReplicas for the terminating cluster. Specifically:

  • If the cluster being deleted has already been assigned replicas, the MaxReplicas is the currently assigned value.
  • Otherwise, the MaxReplicas will be set to 0 to avoid creating new replicas in the terminating cluster.

When the MaxClusters exists at the same time, the scheduler will also give priority to non-terminated clusters when scheduling is triggered, specifically:

  • If there are non-terminated clusters larger than MaxClusters, scheduling will be prioritized in these non-terminated clusters.
  • When the number of non-terminating clusters is less than MaxClusters, the terminating cluster will still be selected by the scheduler. At this time, the number of replicas that can be scheduled will not more then the currently assigned value or be 0

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (68a25a3) 28.59% compared to head (026c6d6) 28.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #263      +/-   ##
==========================================
+ Coverage   28.59%   28.71%   +0.11%     
==========================================
  Files         113      113              
  Lines       13549    13570      +21     
==========================================
+ Hits         3875     3896      +21     
  Misses       9292     9292              
  Partials      382      382              
Flag Coverage Δ
unittests 28.71% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...eduler/framework/plugins/maxcluster/max_cluster.go 92.59% <100.00%> (+2.59%) ⬆️
pkg/controllers/scheduler/scheduler.go 47.20% <100.00%> (ø)
pkg/controllers/scheduler/schedulingunit.go 64.04% <100.00%> (+1.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JackZxj JackZxj force-pushed the fix/prevent-terminating-cluster branch from 2219b67 to 026c6d6 Compare November 9, 2023 04:04
ObjectMeta: metav1.ObjectMeta{
Name: clusterName,
},
}
if terminating {
cluster.DeletionTimestamp = &metav1.Time{Time: time.Now()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (no need to change it for this PR): could simplify this to metav1.Now

su *framework.SchedulingUnit,
clusters []*fedcorev1a1.FederatedCluster,
) {
for _, cluster := range clusters {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we run this regardless of scheduling mode?

@JackZxj JackZxj marked this pull request as draft November 10, 2023 10:46
@JackZxj JackZxj closed this Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants