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

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
Contributor

@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

vladvildanov and others added 21 commits May 13, 2025 20:06
* Fixed flacky TokenManager test

* Fixed additional flacky test

* Removed token count assertion

* Skipped test on version 3.9
add CacheEntry

Co-authored-by: zhousheng06 <[email protected]>
Co-authored-by: Vladyslav Vildanov <[email protected]>
As of PEP 688, type checkers will no longer implicitly consider bytearray to be compatible with bytes
* Moved self._lock initialisation to Pool constructor

* Added test case

* Codestyle fixes

* Added correct annotations
* Changed default dialect to 2

* Codestyle fixes

* Fixed async tests

* Added handling of RESP3 responses

* Fixed flacky tests

* Codestyle fix

* Added separate file to hold default value
* Moved ClusterParser exceptions to BaseParser class

* Codestyle fixes

* Removed ubused imports

* Sorted imports
* DOC-4345 added testable JSON search examples for home page

* DOC-4345 avoid possible non-deterministic results in tests

* DOC-4345 close connection at end of example

* DOC-4345 remove unnecessary blank lines
* Added Redis 8.0 to test matrix

* Fixed test cases

* Added version annotation

* Changed FT.PROFILE response type

* Added version restrictions

* Updated file names, fixed tests assertions

* Removed unused API
* Updated latest image to 8.0-M03-pre

* Changed redis image for testing purposes

* Updated image version

* Updated redis server versions

* Updated test case

* Revert version restriction

* Updated redis versions

* Added tests for new default scorer

* Skipped test on 8.0

* Fixed query to match exact-match syntax

* Codestyle fixes

* Added condition for 8.0-M04-pre image

* Added test for INFO section
* Adding unit text fixes to improve compatibility with MacOS.

* Applying review comments

* Unifying the exception msg validation pattern for both test_connection.py  files

---------

Co-authored-by: Vladyslav Vildanov <[email protected]>
* fix: update redis university url

* fix: add comment to changes

---------

Co-authored-by: Vladyslav Vildanov <[email protected]>
…#3489)

* Adding tests for modules ACL and modules config changes in 8.0

* Applying review comments

* Adding deprecation annotations for tf config commands
…: FT.INFO, just for async client: FT.CONFIG GET and FT.CONFIG SET (redis#3499)
* typing for client __init__

* typing with string literals

* retry_on_error more specific typing

* retry typing

* fix lint

---------

Co-authored-by: Vladyslav Vildanov <[email protected]>
… ft.info will not be deprecated in current release. (redis#3500)
elena-kolevska and others added 25 commits May 13, 2025 20:10
* Marks old RediSearch 1.0 commands as deprecated

* linters
…h ExponentialWithJitterBackoff become the default config. (redis#3614)

* Changing the default retry configuration for Redis standalone clients.

* Updating default retry strategy for standalone clients. 3 retries with ExponentialWithJitterBackoff become the default config.

* Applying review comments - removing unused methods from retry objects, updating pydocs of error handler method
…initialized as part of error handling and retrying of the commands. (redis#3621)
… sync Cluster client to match sync/async cluster APIs (redis#3434)

* Updated default value to much sync cluster API

* Updated default value to TRUE

---------

Co-authored-by: petyaslavova <[email protected]>
…#3622)

* Adding default retry configuration changes for sync cluster client

* Adding default retry configuration changes for sync cluster client

* Adding default retry configuration changes for async cluster client

* Updating docs related to retries and read_from_replicas.

* Applying review comments.

* Removing retry checks when using set_retry for cluster clients.
…security validations are not skipped by default (redis#3626)

* Changing the default value for ssl_check_hostname to True, to ensure security validations  are not skipped by default

* Applying review comments

* Removing unused operation in tests.

* Removing unneeded comment from tests.
…ated with Optional - includes commands in core.py and json commands (redis#3610)

* fix(redis-client): change `zrange` num parameter type to `Optional[int]`

* fix(redis-client): normalize optional parameter annotations

Replace all occurrences of Union[T, None] = None and bare T = None
with Optional[T] = None in zrange, _zrange, arrtrim, and other methods
so that type checkers no longer report errors.

* commit message: fix(redis-client): normalize optional parameter annotations and correct arrtrim return type
body: replaced all Union[T, None] = None and bare T = None with Optional[T] = None; changed arrtrim return annotation to Optional[int]

* fix(redis-client): replace Optional[None] with Optional[int] for numeric parameters
…edis#3633)

* Prevent RuntimeError while reinitializing clusters - sync and async

* Applying copilot's review comments
* Test against unstable hiredis-py

* Create a separate workflow instead

* Remove outdated guard for hiredis-py

The guard was required to prevent cluster tests on RESP3 with hiredis-py before 3.1.0

---------

Co-authored-by: petyaslavova <[email protected]>
* feat(cluster): support for transactions on cluster-aware client

Adds support for transactions based on multi/watch/exec on clusters.
Transactions in this mode are limited to a single hash slot.

Contributed-by: Scopely <[email protected]>

* fix: remove deprecated argument

* remove attributions from code

* Refactor ClusterPipeline to use execution strategies

* Refactored strategy to use composition

* Added test cases

* Sync with master

* Filter tests, ensure that tests are working after refactor

* Added test case

* Revert port changes

* Improved exception handling

* Change visibility of variable to public

* Changed variable ref

* Changed ref type

* Added documentation

* Refactored retries, fixed comments, fixed linters

* Added word to a wordlist

* Revert port changes

* Added quotes

* Fixed docs

* Updated CONNECTION_ERRORS

* Codestyle fixes

* Updated docs

* Revert import

---------

Co-authored-by: vladvildanov <[email protected]>
Co-authored-by: Vladyslav Vildanov <[email protected]>
…erification with ssl_cert_reqs="none", check_hostname is set to False (redis#3637)

* Fix SSL verification with ssl_cert_reqs=none and ssl_check_hostname=True

* Add ssl_check_hostname to REDIS_ALLOWED_KEYS and fix default value in RedisSSLContext
@petyaslavova
Copy link
Collaborator

Hi @Kakadus,
I tried to complete the changes for this PR, but while resolving conflicts and merging with master, I accidentally included the master commits as new ones. To avoid risking any issues with the Git history, I’ve recreated your changes in a new PR: #3646.
Apologies for the mess — and thank you for your understanding!
I’ll go ahead and close this PR now.

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