Fix cluster mode connecting to same node for all shards#35
Open
ajGingrich wants to merge 2 commits intomainfrom
Open
Fix cluster mode connecting to same node for all shards#35ajGingrich wants to merge 2 commits intomainfrom
ajGingrich wants to merge 2 commits intomainfrom
Conversation
In cluster mode, process_node() was always connecting to the config entry-point host/port instead of the discovered node's address. This caused all cluster nodes to report identical metrics (memory, throughput, command stats) since they were all querying the same Redis instance. The fix uses the node address (host:port) from cluster discovery for the Redis connection while preserving auth and TLS settings from config. Non-cluster mode was unaffected since the single-node address already matched the config values. Made-with: Cursor
Add a ping check after creating the Redis client in process_node(). If a discovered cluster node is unreachable (e.g. behind NAT, load balancer, or firewall), return None with a warning instead of crashing the entire collection run for that database. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process_node()always connected to the config entry-point host/port (config.get("host")/config.get("port")) instead of the actual discovered node address passed via thenodeparameter. This meant every node in a Redis cluster was queried from the same instance, producing identical metrics across all masters and replicas.nodeparameter) for the Redis connection, while preserving authentication and TLS settings from config.process_database()constructs the node address fromconfig["host"]:config["port"], so the values already matched.Problem Detail
When
process_database()discovers cluster nodes viaCLUSTER NODES, it iterates over each discoveredhost:portand passes it toprocess_node(). However,process_node()was ignoring the node address and always creating the Redis client with:This caused all 6 rows in a 3-master/3-replica cluster to show identical values for memory, throughput, and command stats.
Changes
osstats.py: Parsenodeintonode_hostandnode_port, and use those for theget_redis_client()calltest_osstats.py: Addedtest_process_node_connects_to_discovered_nodewhich uses a different node address than the config entry-point, verifyingget_redis_clientis called with the discovered node's host/portTest plan
pytest -v)black --check .)Made with Cursor