Skip to content

Add dynamic_startup_nodes parameter to async RedisCluster #3447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kakadus
Copy link

@Kakadus Kakadus commented Nov 28, 2024

Pull Request check-list

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

Description of change

The async version of the RedisCluster lacked the dynamic_startup_nodes parameter. This PR adds the parameter to be activated when dynamic DNS endpoints for startup nodes are in use.

Enabling dynamic_startup_nodes fixes #2472, which describes the problem in detail.

#3111 also addresses said issue, but their logic is different to the sync version, while this approach moves the behaviour of the async version closer to the sync version.

@Kakadus Kakadus force-pushed the add-dynamic-startup-nodes-flag-to-async-redis-cluster branch from c9ca010 to cce34d7 Compare November 28, 2024 19:09
@Kakadus Kakadus force-pushed the add-dynamic-startup-nodes-flag-to-async-redis-cluster branch from cce34d7 to dd2ee3f Compare December 10, 2024 20:11
@julianhille
Copy link

any news here? this looks good to me

@petyaslavova
Copy link
Collaborator

Hi @Kakadus would you have some time to complete this PR. There are some conflicts with the master branch that need to be resolved.

@petyaslavova petyaslavova requested a review from Copilot May 9, 2025 13:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the "dynamic_startup_nodes" parameter to the async RedisCluster, aligning its behavior with the sync version.

  • Introduces a new parameter to enable or disable dynamic DNS resolution for startup nodes.
  • Implements handling in both the NodesManager and RedisCluster initialization.
  • Adds parameterized tests to verify behavior with both True and False values.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/test_asyncio/test_cluster.py Adds tests for dynamic startup nodes behavior using parameterized inputs
redis/asyncio/cluster.py Updates RedisCluster and NodesManager to support the new dynamic_startup_nodes parameter
CHANGES Documents the addition of the dynamic_startup_nodes parameter

]
startup_nodes = list(rc.nodes_manager.startup_nodes.keys())
if dynamic_startup_nodes is True:
assert startup_nodes.sort() == discovered_nodes.sort()
Copy link
Preview

Copilot AI May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using list.sort() returns None; please use sorted(startup_nodes) and sorted(discovered_nodes) to correctly compare the lists.

Suggested change
assert startup_nodes.sort() == discovered_nodes.sort()
assert sorted(startup_nodes) == sorted(discovered_nodes)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

async redis cluster should use initial startup nodes during reinitialization in case of failover
3 participants