-
Notifications
You must be signed in to change notification settings - Fork 499
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
document and improve HA algorithm #670
Conversation
/run-e2e-tests |
LGTM |
pkg/scheduler/predicates/ha.go
Outdated
if podsCount+1 >= int(replicas+1)/2 { | ||
// When replicas equals 3, pods on each node should not be greater than 1. | ||
maxPodsPerNode := 1 | ||
if replicas > 3 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3
is hard-coded, but it should be gathered from configuration (in case the user sets it to 5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3
is the tikv replicas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr just fix the corner case when replicas is 4.
it has some conflicts, I will resolve it later |
@xiaojingchen @weekface conflicts are resolved, PTAL again. Thanks! |
/run-e2e-tests |
pkg/scheduler/predicates/ha.go
Outdated
maxPodsPerNode := 1 | ||
if replicas > 3 { | ||
// When replicas is greater than 3, we allow more than one pods on one node. | ||
maxPodsPerNode = int((replicas + 1) / 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if replicas =5
, the maxPodsPerNode
would be 3
. Is it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems not right... 2, 3
will be possible when there are only two nodes.
int((replicas + 1) / 2)
should be ceil(replicas / 3)
replicas | maxPodsPerNode | three nodes | less than three nodes |
---|---|---|---|
< 3 | not limited, because HA is not possible | possible, no HA is required | possible, no HA is required |
= 3 | 1 | 1, 1, 1 | not possible, requires HA in three nodes |
4 | 2 | 1, 1, 2 | not possible, requires HA in three nodes |
5 | 2 | 1, 2, 2 | not possible, requires HA in three nodes |
6 | 2 | 2, 2, 2 | not possible, requires HA in three nodes |
7 | 3 | 2, 2, 3 | not possible, requires HA in three nodes |
8 | 3 | 2, 3, 3 | not possible, requires HA in three nodes |
8 | 3 | 3, 3, 3 | not possible, requires HA in three nodes |
what do you think? @weekface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the table above, the maxPodsPerNode
is 2
when replicas
is 4
, this is not HA for pd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the maxPodsPerNode
is right when replicas
is 4
, because in three nodes, 1, 1, 2
is ok, but when there are two instances in two nodes (1, 1
), maxPodsPerNode
must be 1
at this moment to force the scheduler to find a node which has no TiKV pod.
I guess we need to update the HA algorithm to take more information into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxPodsPerNode
is always 1
when scheduled TiKV pods less than 3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current algorithm is ok for pd
, but not tikv
. We need a new HA algorithm for tikv
.
@weekface @xiaojingchen PTAL again. |
cd80f80
to
131f76d
Compare
if component != label.PDLabelVal && component != label.TiKVLabelVal { | ||
glog.V(4).Infof("component %s is ignored in HA predicate", component) | ||
return nodes, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a safe guard and improves readability
name: "three nodes, three pods scheduled on these three nodes, replicas is 4, can't scheduled", | ||
podFn: newHAPDPod, | ||
name: "three nodes, three pods scheduled on these three nodes, replicas is 4, return all the three nodes", | ||
podFn: newHATiKVPod, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this case is for TiKV, we need a TiKV pod
/run-e2e-tests |
pkg/scheduler/predicates/ha.go
Outdated
* --------------------------- | ||
* 1 1 | ||
* 2 1 | ||
* 3 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please align
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I mixed tab and spaces, fixed now.
/run-e2e-tests |
1 similar comment
/run-e2e-tests |
@weekface should this be merged before 1.0 GA? |
Yes, merging it to master. But I will not cherry-pick it to the |
cherry pick to release-1.0 failed |
cherry pick to release-1.1 failed |
/run-cherry-picker |
2 similar comments
/run-cherry-picker |
/run-cherry-picker |
* fix the corner case when replicas is 4 * improve HA algorithm for TiKV/PD
What problem does this PR solve?
fixes #652
What is changed and how does it work?
Check List
Tests
Code changes
Does this PR introduce a user-facing change?: