Skip to content

Commit

Permalink
c/shard_balancer: enable persistence when the feature barrier allows
Browse files Browse the repository at this point in the history
  • Loading branch information
ztlpn committed May 17, 2024
1 parent caa89ca commit faa76fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/v/cluster/controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ ss::future<> controller::start(
.then([this] {
return _shard_balancer.start_single(
std::ref(_shard_placement),
std::ref(_feature_table),
std::ref(_tp_state),
std::ref(_backend));
})
Expand Down
13 changes: 13 additions & 0 deletions src/v/cluster/shard_balancer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ namespace cluster {

shard_balancer::shard_balancer(
ss::sharded<shard_placement_table>& spt,
ss::sharded<features::feature_table>& features,
ss::sharded<topic_table>& topics,
ss::sharded<controller_backend>& cb)
: _shard_placement(spt.local())
, _features(features.local())
, _topics(topics)
, _controller_backend(cb)
, _self(*config::node().node_id()) {}
Expand Down Expand Up @@ -94,6 +96,11 @@ ss::future<> shard_balancer::start() {
co_await do_assign_ntps();
} else {
co_await _shard_placement.initialize_from_topic_table(_topics, _self);

if (_features.is_active(
features::feature::shard_placement_persistence)) {
co_await _shard_placement.enable_persistence();
}
}

vassert(
Expand Down Expand Up @@ -146,6 +153,12 @@ ss::future<> shard_balancer::assign_fiber() {
co_return;
}

if (
_features.is_active(features::feature::shard_placement_persistence)
&& !_shard_placement.is_persistence_enabled()) {
co_await _shard_placement.enable_persistence();
}

co_await do_assign_ntps();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/v/cluster/shard_balancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class shard_balancer {

shard_balancer(
ss::sharded<shard_placement_table>&,
ss::sharded<features::feature_table>&,
ss::sharded<topic_table>&,
ss::sharded<controller_backend>&);

Expand All @@ -47,6 +48,7 @@ class shard_balancer {

private:
shard_placement_table& _shard_placement;
features::feature_table& _features;
ss::sharded<topic_table>& _topics;
ss::sharded<controller_backend>& _controller_backend;
model::node_id _self;
Expand Down

0 comments on commit faa76fd

Please sign in to comment.