Skip to content
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

Extended "CLUSTER NODES" parser to support special slot entries #2080

Merged
merged 2 commits into from
Apr 4, 2022

Conversation

barshaul
Copy link
Contributor

@barshaul barshaul commented Apr 3, 2022

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • 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?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Extended "CLUSTER NODES" parser to support special slot entries (importing, migrating).
The returned dictionary will also contain another field called 'migrations' that will hold slots that are in migration process.
See https://redis.io/commands/cluster-nodes/#special-slot-entries for more info.

For example, for the following cluster:

49962d9126b7e587c7c93e9899df075055846123 127.0.0.1:16381@26381 master - 0 1648980066000 3 connected 10923-16383
bcded50bc75187199679b0cc7380b3240724b834 127.0.0.1:16379@26379 myself,master - 0 1648980062000 1 connected 0-5460 [1->-a0bb8017ee950c73510741f866f5ebf2aebc5662]
a0bb8017ee950c73510741f866f5ebf2aebc5662 127.0.0.1:16380@26380 master - 0 1648980065000 2 connected 5461-10922

the returned entry for node 16379 is:

print(r.cluster_nodes().get("127.0.0.1:16379"))
{'node_id': 'bcded50bc75187199679b0cc7380b3240724b834', 
'flags': 'myself,master', 
'master_id': '-', 
'last_ping_sent': '0', 
'last_pong_rcvd': '1648980178000', 
'epoch': '1',
 'slots': [['0', '5460']],
 'migrations': [{'slot': '1', 'node_id': 'a0bb8017ee950c73510741f866f5ebf2aebc5662', 'state': 'migrating'}],
 'connected': True}

@codecov-commenter
Copy link

codecov-commenter commented Apr 3, 2022

Codecov Report

Merging #2080 (6a418f1) into master (143107a) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2080      +/-   ##
==========================================
+ Coverage   91.18%   91.19%   +0.01%     
==========================================
  Files         100      100              
  Lines       21456    21485      +29     
==========================================
+ Hits        19564    19593      +29     
  Misses       1892     1892              
Impacted Files Coverage Δ
redis/client.py 89.46% <100.00%> (+0.16%) ⬆️
tests/test_cluster.py 97.36% <100.00%> (-0.10%) ⬇️
redis/asyncio/connection.py 82.52% <0.00%> (+0.11%) ⬆️
redis/asyncio/client.py 90.63% <0.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 143107a...6a418f1. Read the comment docs.

@barshaul barshaul marked this pull request as ready for review April 3, 2022 10:14
Copy link
Collaborator

@dvora-h dvora-h left a comment

Choose a reason for hiding this comment

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

Thanks for that!

@dvora-h dvora-h added feature New feature breakingchange API or Breaking Change labels Apr 4, 2022
@dvora-h dvora-h merged commit 0676892 into redis:master Apr 4, 2022
@ma2sql ma2sql mentioned this pull request Apr 4, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakingchange API or Breaking Change feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants