diff --git a/pkg/kv/kvserver/rebalance_objective.go b/pkg/kv/kvserver/rebalance_objective.go index 3514f3c4fc99..268db3fb8c23 100644 --- a/pkg/kv/kvserver/rebalance_objective.go +++ b/pkg/kv/kvserver/rebalance_objective.go @@ -92,6 +92,17 @@ const ( LBRebalancingCPU ) +// LoadBasedRebalancingObjectiveMap maps the LoadBasedRebalancingObjective enum +// value to a string. +var LoadBasedRebalancingObjectiveMap map[int64]string = map[int64]string{ + int64(LBRebalancingQueries): "qps", + int64(LBRebalancingCPU): "cpu", +} + +func (lbro LBRebalancingObjective) String() string { + return LoadBasedRebalancingObjectiveMap[int64(lbro)] +} + // LoadBasedRebalancingObjective is a cluster setting that defines the load // balancing objective of the cluster. var LoadBasedRebalancingObjective = settings.RegisterEnumSetting( @@ -101,10 +112,7 @@ var LoadBasedRebalancingObjective = settings.RegisterEnumSetting( "the cluster will attempt to balance qps among stores, if set to "+ "`cpu` the cluster will attempt to balance cpu usage among stores", "cpu", - map[int64]string{ - int64(LBRebalancingQueries): "qps", - int64(LBRebalancingCPU): "cpu", - }, + LoadBasedRebalancingObjectiveMap, ).WithPublic() // ToDimension returns the equivalent allocator load dimension of a rebalancing diff --git a/pkg/kv/kvserver/store_rebalancer.go b/pkg/kv/kvserver/store_rebalancer.go index 2f67ad2c0ddf..bc290abb6436 100644 --- a/pkg/kv/kvserver/store_rebalancer.go +++ b/pkg/kv/kvserver/store_rebalancer.go @@ -276,6 +276,9 @@ func (sr *StoreRebalancer) Start(ctx context.Context, stopper *stop.Stopper) { continue } objective := sr.RebalanceObjective() + sr.AddLogTag("obj", objective) + ctx = sr.AnnotateCtx(ctx) + hottestRanges := sr.replicaRankings.TopLoad(objective.ToDimension()) options := sr.scorerOptions(ctx, objective.ToDimension()) rctx := sr.NewRebalanceContext(ctx, options, hottestRanges, mode)