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
*: region filter #5135
*: region filter #5135
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Codecov Report
@@ Coverage Diff @@
## master #5135 +/- ##
==========================================
- Coverage 75.69% 75.66% -0.03%
==========================================
Files 311 312 +1
Lines 30909 30962 +53
==========================================
+ Hits 23396 23427 +31
- Misses 5503 5523 +20
- Partials 2010 2012 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
aaca3b8
to
73b48dd
Compare
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
73b48dd
to
bf21523
Compare
server/schedule/healthy.go
Outdated
) | ||
|
||
// IsRegionHealthy checks if a region is healthy for scheduling. It requires the | ||
// region does not have any down or pending peers. | ||
func IsRegionHealthy(region *core.RegionInfo) bool { | ||
return IsRegionHealthyAllowPending(region) && len(region.GetPendingPeers()) == 0 | ||
pendingFilter := filter.NewRegionPengdingFilter("option") |
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.
Why not keep them as it is?
} | ||
|
||
// Cluster provides an overview of a cluster's regions distribution. | ||
type Cluster interface { |
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.
Can we avoid defining this interface?
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 defined this because of avoiding import cycles
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.
defining this interface looks ok to me, However could we make the interface private?
server/schedule/filter/filters.go
Outdated
@@ -137,7 +137,7 @@ func Target(opt *config.PersistOptions, store *core.StoreInfo, filters []Filter) | |||
storeAddress := store.GetAddress() | |||
storeID := strconv.FormatUint(store.GetID(), 10) | |||
for _, filter := range filters { | |||
if !filter.Target(opt, store).IsOK() { | |||
if filter.Target(opt, store) != statusStoreOK { |
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.
Could we use IsOK
?
server/schedule/filter/filters.go
Outdated
statusPauseLeader = plan.NewStatus(plan.StatusStoreBlocked, "the store is not allowed to transfer leader, there might be an evict-leader-scheduler") | ||
statusRejectLeader = plan.NewStatus(plan.StatusStoreBlocked, "the store is not allowed to transfer leader, please check 'label-property'") | ||
statusSlowStore = plan.NewStatus(plan.StatusStoreBlocked, "the store is slow and are evicting leaders, there might be an evict-slow-store-scheduler") | ||
statusStoreOK = plan.NewStatus(plan.StatusOK) |
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.
Could we merge statusStoreOK
with statusRegionOK
?
How about defining a single file status.go
to store these status variables?
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 that only statusOK
needs a single file, is it necessary?
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.
How about put all status
into that file?
return statusRegionOK | ||
} | ||
|
||
// isEmptyRegionAllowBalance checks if a region is an empty region and can be balanced. |
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.
// isEmptyRegionAllowBalance checks if a region is an empty region and can be balanced. | |
// isEmptyRegionAllowBalance returns true if the region is not empty or the number of regions is too small. |
} | ||
|
||
// Cluster provides an overview of a cluster's regions distribution. | ||
type Cluster interface { |
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.
defining this interface looks ok to me, However could we make the interface private?
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
server/schedule/healthy.go
Outdated
return cluster.GetRuleManager().FitRegion(cluster, region).IsSatisfied() | ||
} | ||
return len(region.GetLearners()) == 0 && len(region.GetPeers()) == cluster.GetOpts().GetMaxReplicas() | ||
filter := filter.NewRegionReplicatedFilter("option", cluster) |
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.
ditto
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 Replicated is a more complex logic than PendingPeer or DownPeer, so I only want to maintain it in one place
} | ||
return statusNoNeed | ||
return statusStoreNoNeed |
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.
How about keep using statusNoNeed
?
} | ||
|
||
// cluster provides an overview of a cluster's regions distribution. | ||
type regionFilterCluster interface { |
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.
seem that some interfaces are not used
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.
update
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
return hasDownPeers(region) | ||
} | ||
|
||
func hasPendingPeers(region *core.RegionInfo) bool { |
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 name doesn't match the implementation.
return len(region.GetPendingPeers()) == 0 | ||
} | ||
|
||
func hasDownPeers(region *core.RegionInfo) bool { |
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.
ditto
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.
LGTM
return statusOK | ||
} | ||
if !isRegionReplicasSatisfied(f.cluster, region) { | ||
return statusRegionIsolation |
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.
Why is it related to isolation?
// RegionFilter is an interface to filter region. | ||
type RegionFilter interface { | ||
// RegionFilter is used to indicate where the filter will act on. | ||
Scope() string |
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.
Is it needed?
|
||
import "github.com/tikv/pd/server/schedule/plan" | ||
|
||
var ( |
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.
Why not put them together if you use a separate file to define the status?
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
server/schedule/plan/status.go
Outdated
@@ -46,6 +46,8 @@ const ( | |||
StatusRegionUnhealthy | |||
// StatusRegionEmpty represents the region cannot be selected due to the region is empty. | |||
StatusRegionEmpty | |||
// StatusRegionUnReplicated represents the region does not have enough replicas. | |||
StatusRegionUnReplicated |
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.
StatusRegionUnReplicated | |
StatusRegionNotReplicated |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
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 rest LGTM.
server/schedule/filter/filters.go
Outdated
@@ -505,17 +483,17 @@ func (f *StoreStateFilter) Source(opts *config.PersistOptions, store *core.Store | |||
// target. | |||
func (f *StoreStateFilter) Target(opts *config.PersistOptions, store *core.StoreInfo) (status plan.Status) { | |||
if f.TransferLeader { | |||
if status = f.anyConditionMatch(leaderTarget, opts, store); !status.IsOK() { |
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.
Why change it back?
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
/merge |
@rleungx: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 987a1fa
|
Signed-off-by: Cabinfever_B cabinfeveroier@gmail.com
What problem does this PR solve?
Issue Number: ref #5257
What is changed and how does it work?
remove
RegionOption
, and addRegionFilter
Check List
Tests
Release note