Skip to content

Commit

Permalink
fix: Check for balancer in peer_cluster role property
Browse files Browse the repository at this point in the history
  • Loading branch information
Batalex committed Oct 29, 2024
1 parent 6962f6d commit 4cc2383
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/managers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from core.workload import CharmedKafkaPaths, WorkloadBase
from literals import (
ADMIN_USER,
BALANCER,
BALANCER_GOALS_TESTING,
BROKER,
DEFAULT_BALANCER_GOALS,
Expand Down Expand Up @@ -604,9 +605,7 @@ def server_properties(self) -> list[str]:
if self.state.cluster.tls_enabled and self.state.unit_broker.certificate:
properties += self.tls_properties + self.zookeeper_tls_properties

# FIXME: change peer_cluster_relation to peer_cluster_orchestrator_relations after the center-of-star
# change is effective
if self.state.runs_balancer or self.state.peer_cluster_relation:
if self.state.runs_balancer or BALANCER.value in self.state.peer_cluster.roles:
properties += KAFKA_CRUISE_CONTROL_OPTIONS.splitlines()
properties += self.metrics_reporter_properties

Expand Down
11 changes: 7 additions & 4 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
JVM_MEM_MIN_GB,
OAUTH_REL_NAME,
PEER,
PEER_CLUSTER_RELATION,
PEER_CLUSTER_ORCHESTRATOR_RELATION,
REL_NAME,
SUBSTRATE,
ZK,
Expand Down Expand Up @@ -583,9 +583,12 @@ def test_cruise_control_reporter_only_with_balancer(harness: Harness[KafkaCharm]
# Default roles value does not include balancer
assert reporters_config_value not in harness.charm.broker.config_manager.server_properties

# FIXME: change peer_cluster_relation to peer_cluster_orchestrator_relations after the center-of-star
# change is effective
with harness.hooks_disabled():
harness.add_relation(PEER_CLUSTER_RELATION, "balancer")
peer_cluster_relation_id = harness.add_relation(
PEER_CLUSTER_ORCHESTRATOR_RELATION, CHARM_KEY
)
harness.update_relation_data(
peer_cluster_relation_id, harness.charm.app.name, {"roles": "broker,balancer"}
)

assert reporters_config_value in harness.charm.broker.config_manager.server_properties

0 comments on commit 4cc2383

Please sign in to comment.