Skip to content

Commit

Permalink
ccmlib/scylla_node: stop hardcoding api_port
Browse files Browse the repository at this point in the history
servel place in the code were assuming that `api_port` would be 10000.

some tests in the java-driver we setting `api_port` to a random port
hence breaking some of the ccm functionality, like nodetool and
wait_for_other_notice logic

(cherry picked from commit 9370f29)
  • Loading branch information
fruch committed Sep 15, 2024
1 parent db97bb1 commit 9be7025
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions ccmlib/scylla_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from ccmlib.utils.version import parse_version


yaml = YAML()
yaml = YAML(typ='safe')
yaml.default_flow_style = False

class ScyllaNode(Node):
Expand Down Expand Up @@ -115,6 +115,14 @@ def has_jmx(self):

return self._has_jmx

@property
def scylla_yaml(self) -> Dict[str, Any]:
return yaml.load(Path(self.get_conf_dir()) / common.SCYLLA_CONF)

@property
def api_port(self) -> int:
return self.scylla_yaml.get('api_port', 10000)

def scylla_mode(self):
return self.cluster.get_scylla_mode()

Expand Down Expand Up @@ -370,7 +378,7 @@ def _create_agent_config(self):
data['logger'] = dict(level='debug')
data['debug'] = f"{self.address()}:56112"
data['scylla'] = {'api_address': f"{self.address()}",
'api_port': 10000}
'api_port': self.api_port}
data['prometheus'] = f"{self.address()}:56090"
data['s3'] = {"endpoint": os.getenv("AWS_S3_ENDPOINT"), "provider": "Minio"}

Expand Down Expand Up @@ -789,7 +797,7 @@ def nodetool(self, cmd, capture_output=True, wait=True, timeout=None, verbose=Tr
host = 'localhost'
else:
host = self.address()
nodetool.extend(['-h', host, '-p', '10000'])
nodetool.extend(['-h', host, '-p', str(self.api_port)])
nodetool.extend(cmd.split())
return self._do_run_nodetool(nodetool, capture_output, wait, timeout, verbose)
except subprocess.CalledProcessError:
Expand All @@ -802,7 +810,7 @@ def nodetool(self, cmd, capture_output=True, wait=True, timeout=None, verbose=Tr

# pass the api_port to nodetool. if it is the nodetool-wrapper. it should
# interpret the command line and use it for the -p option
cmd = f"-Dcom.scylladb.apiPort=10000 {cmd}"
cmd = f"-Dcom.scylladb.apiPort={self.api_port} {cmd}"
try:
return super().nodetool(cmd, capture_output, wait, timeout, verbose)
except subprocess.TimeoutExpired:
Expand Down Expand Up @@ -1380,7 +1388,7 @@ def hostid(self, timeout=60, force_refresh=False):
return self.node_hostid
try:
node_address = self.address()
url = f"http://{node_address}:10000/storage_service/hostid/local"
url = f"http://{node_address}:{self.api_port}/storage_service/hostid/local"
response = requests.get(url=url, timeout=timeout)
if response.status_code == requests.codes.ok:
self.node_hostid = response.json()
Expand All @@ -1407,10 +1415,10 @@ def watch_rest_for_alive(self, nodes, timeout=120, wait_normal_token_owner=True)
tofind_host_id_map = dict([(node.address(), node.hostid()) for node in nodes_tofind])
found = set()
found_host_id_map = dict()
url_live = f"http://{self.address()}:10000/gossiper/endpoint/live"
url_joining = f"http://{self.address()}:10000/storage_service/nodes/joining"
url_tokens = f"http://{self.address()}:10000/storage_service/tokens/"
url_host_ids = f"http://{self.address()}:10000/storage_service/host_id"
url_live = f"http://{self.address()}:{self.api_port}/gossiper/endpoint/live"
url_joining = f"http://{self.address()}:{self.api_port}/storage_service/nodes/joining"
url_tokens = f"http://{self.address()}:{self.api_port}/storage_service/tokens/"
url_host_ids = f"http://{self.address()}:{self.api_port}/storage_service/host_id"
endtime = time.time() + timeout
while time.time() < endtime:
live = set()
Expand Down

0 comments on commit 9be7025

Please sign in to comment.