Skip to content

Commit db79cff

Browse files
authored
Merge pull request #305 from avelanarius/improve-is-valid-peer-logs
cluster: improve logging of peers row validation
2 parents 49a136e + 3815f53 commit db79cff

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

cassandra/cluster.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,9 +3950,6 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
39503950
should_rebuild_token_map = force_token_rebuild or self._cluster.metadata.partitioner is None
39513951
for row in peers_result:
39523952
if not self._is_valid_peer(row):
3953-
log.warning(
3954-
"Found an invalid row for peer (%s). Ignoring host." %
3955-
_NodeInfo.get_broadcast_rpc_address(row))
39563953
continue
39573954

39583955
endpoint = self._cluster.endpoint_factory.create(row)
@@ -4019,9 +4016,40 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
40194016

40204017
@staticmethod
40214018
def _is_valid_peer(row):
4022-
return bool(_NodeInfo.get_broadcast_rpc_address(row) and row.get("host_id") and
4023-
row.get("data_center") and row.get("rack") and
4024-
('tokens' not in row or row.get('tokens')))
4019+
broadcast_rpc = _NodeInfo.get_broadcast_rpc_address(row)
4020+
host_id = row.get("host_id")
4021+
4022+
if not broadcast_rpc:
4023+
log.warning(
4024+
"Found an invalid row for peer - missing broadcast_rpc (full row: %s). Ignoring host." %
4025+
row)
4026+
return False
4027+
4028+
if not host_id:
4029+
log.warning(
4030+
"Found an invalid row for peer - missing host_id (broadcast_rpc: %s). Ignoring host." %
4031+
broadcast_rpc)
4032+
return False
4033+
4034+
if not row.get("data_center"):
4035+
log.warning(
4036+
"Found an invalid row for peer - missing data_center (broadcast_rpc: %s, host_id: %s). Ignoring host." %
4037+
(broadcast_rpc, host_id))
4038+
return False
4039+
4040+
if not row.get("rack"):
4041+
log.warning(
4042+
"Found an invalid row for peer - missing rack (broadcast_rpc: %s, host_id: %s). Ignoring host." %
4043+
(broadcast_rpc, host_id))
4044+
return False
4045+
4046+
if "tokens" in row and not row.get("tokens"):
4047+
log.warning(
4048+
"Found an invalid row for peer - tokens is None (broadcast_rpc: %s, host_id: %s). Ignoring host." %
4049+
(broadcast_rpc, host_id))
4050+
return False
4051+
4052+
return True
40254053

40264054
def _update_location_info(self, host, datacenter, rack):
40274055
if host.datacenter == datacenter and host.rack == rack:

0 commit comments

Comments
 (0)