Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Nov 1, 2024
1 parent 853fc4a commit fd8e541
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 0 additions & 3 deletions pkg/schedule/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,6 @@ func (s *balanceLeaderScheduler) createOperator(solver *solver, collector *plan.
solver.calcTargetStoreScore(s.GetName())
if !solver.shouldBalance(s.GetName()) {
balanceLeaderSkipCounter.Inc()
if solver.isPotentialReverse() {
balanceLeaderPotentialReverse.Inc()
}
if collector != nil {
collector.Collect(plan.SetStatus(plan.NewStatus(plan.StatusStoreScoreDisallowed)))
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/schedule/schedulers/balance_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,14 @@ func (s *balanceRegionScheduler) transferPeer(solver *solver, collector *plan.Co
regionID := solver.Region.GetID()
sourceID := solver.Source.GetID()
targetID := solver.Target.GetID()
sourceLabel := strconv.FormatUint(sourceID, 10)
targetLabel := strconv.FormatUint(targetID, 10)
log.Debug("candidate store", zap.Uint64("region-id", regionID), zap.Uint64("source-store", sourceID), zap.Uint64("target-store", targetID))

if !solver.shouldBalance(s.GetName()) {
balanceRegionSkipCounter.Inc()
if solver.isPotentialReverse() {
balanceRegionPotentialReverse.Inc()
balancePotentialReverseCounter.WithLabelValues(s.GetName(), sourceLabel, targetLabel)
}
if collector != nil {
collector.Collect(plan.SetStatus(plan.NewStatus(plan.StatusStoreScoreDisallowed)))
Expand All @@ -254,8 +256,6 @@ func (s *balanceRegionScheduler) transferPeer(solver *solver, collector *plan.Co
collector.Collect()
}
solver.Step--
sourceLabel := strconv.FormatUint(sourceID, 10)
targetLabel := strconv.FormatUint(targetID, 10)
op.FinishedCounters = append(op.FinishedCounters,
balanceDirectionCounter.WithLabelValues(s.GetName(), sourceLabel, targetLabel),
)
Expand Down
10 changes: 8 additions & 2 deletions pkg/schedule/schedulers/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ var (
Help: "Counter of direction of balance related schedulers.",
}, []string{"type", "source", "target"})

balancePotentialReverseCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "pd",
Subsystem: "scheduler",
Name: "potential_reverse",
Help: "Counter of direction which would introduce potential reverse.",
}, []string{"type", "source", "target"})

// TODO: pre-allocate gauge metrics
hotDirectionCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand Down Expand Up @@ -229,7 +237,6 @@ var (
balanceLeaderNoTargetStoreCounter = balanceLeaderCounterWithEvent("no-target-store")
balanceLeaderNoFollowerRegionCounter = balanceLeaderCounterWithEvent("no-follower-region")
balanceLeaderSkipCounter = balanceLeaderCounterWithEvent("skip")
balanceLeaderPotentialReverse = balanceLeaderCounterWithEvent("potential-reverse")
balanceLeaderNewOpCounter = balanceLeaderCounterWithEvent("new-operator")

balanceRegionScheduleCounter = balanceRegionCounterWithEvent("schedule")
Expand All @@ -238,7 +245,6 @@ var (
balanceRegionNoLeaderCounter = balanceRegionCounterWithEvent("no-leader")
balanceRegionNewOpCounter = balanceRegionCounterWithEvent("new-operator")
balanceRegionSkipCounter = balanceRegionCounterWithEvent("skip")
balanceRegionPotentialReverse = balanceRegionCounterWithEvent("potential-reverse")
balanceRegionCreateOpFailCounter = balanceRegionCounterWithEvent("create-operator-fail")
balanceRegionNoReplacementCounter = balanceRegionCounterWithEvent("no-replacement")

Expand Down

0 comments on commit fd8e541

Please sign in to comment.