Skip to content

Commit

Permalink
scheduler: add source filter to transferLeaderIn
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Sep 12, 2024
1 parent cbdc8c3 commit 1d01a8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/schedule/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,18 @@ func (l *balanceLeaderScheduler) transferLeaderIn(solver *solver, collector *pla
balanceLeaderNoLeaderRegionCounter.Inc()
return nil
}
finalFilters := l.filters

// Check if the source store is available as a source.
conf := solver.GetSchedulerConfig()
if filter.NewCandidates([]*core.StoreInfo{solver.Source}).
FilterSource(conf, nil, l.filterCounter, l.filters...).Len() == 0 {
log.Debug("store cannot be used as source", zap.String("scheduler", l.GetName()), zap.Uint64("store-id", solver.Source.GetID()))
balanceLeaderNoSourceStoreCounter.Inc()
return nil
}

// Check if the target store is available as a target.
finalFilters := l.filters
if leaderFilter := filter.NewPlacementLeaderSafeguard(l.GetName(), conf, solver.GetBasicCluster(), solver.GetRuleManager(), solver.Region, solver.Source, false /*allowMoveLeader*/); leaderFilter != nil {
finalFilters = append(l.filters, leaderFilter)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/schedule/schedulers/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ var (
balanceLeaderScheduleCounter = balanceLeaderCounterWithEvent("schedule")
balanceLeaderNoLeaderRegionCounter = balanceLeaderCounterWithEvent("no-leader-region")
balanceLeaderRegionHotCounter = balanceLeaderCounterWithEvent("region-hot")
balanceLeaderNoSourceStoreCounter = balanceLeaderCounterWithEvent("no-source-store")
balanceLeaderNoTargetStoreCounter = balanceLeaderCounterWithEvent("no-target-store")
balanceLeaderNoFollowerRegionCounter = balanceLeaderCounterWithEvent("no-follower-region")
balanceLeaderSkipCounter = balanceLeaderCounterWithEvent("skip")
Expand Down

0 comments on commit 1d01a8e

Please sign in to comment.