Skip to content

redis: add support for hostnames returned in cluster_slots response#19541

Merged
mattklein123 merged 23 commits intoenvoyproxy:mainfrom
huntsman90:elasticache_redis_hostnames
Feb 28, 2022
Merged

redis: add support for hostnames returned in cluster_slots response#19541
mattklein123 merged 23 commits intoenvoyproxy:mainfrom
huntsman90:elasticache_redis_hostnames

Conversation

@huntsman90
Copy link
Copy Markdown
Contributor

@huntsman90 huntsman90 commented Jan 13, 2022

Commit Message:

Currently, CLUSTER SLOTS response is expected to contain the IP address of each redis host in the response.
However, response from AWS Elasticache contains the hostnames instead. This PR adds support to DNS resolve the hostnames asynchronously before cluster slot updates are applied.

Co-authored-by: Konstantin Belyalov arsenicus@mail.ru

Additional Description:

This PR builds directly on top of #19192 and fixes the bugs in it.

To read this PR, the best starting point may be the onResponse method in redis_cluster.cc and read from there. Almost all of the logic change is confined to redis_cluster.cc.

The failure scenarios while resolving the hostnames are listed below:

  1. If the DNS resolution for any of the primary redis entries fails, we stop the entire resolution, log an error, and reset the resolve timer.
  2. If the DNS resolution for any of the replicas fails, we still continue on, skipping that replica. A warning is logged instead.
  3. In both scenarios, counter update_failure_ is incremented.

Testing:

  • Unit tests
  • We also tested this manually in an AWS setup, and it worked great

Fixes #8440

belyalov and others added 7 commits January 13, 2022 10:11
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
- refactor code to make more readable, and simplify recursion logic
- do not fail entire resolution if a replica resolution fails
- add test, fix existing one

Co-authored-by: Konstantin Belyalov <arsenicus@mail.ru>

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@repokitteh-read-only
Copy link
Copy Markdown

Hi @huntsman90, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #19541 was opened by huntsman90.

see: more, trace.

@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #19541 was opened by huntsman90.

see: more, trace.

@huntsman90 huntsman90 marked this pull request as ready for review January 13, 2022 18:39
…ponse using addrInfo()

- ran code formatter, which changed some unrelated code, but it mostly looks fine.

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@alyssawilk
Copy link
Copy Markdown
Contributor

Hey @snowp redis is owned by Matt, but could you field reviews until he's back?

Copy link
Copy Markdown
Contributor

@snowp snowp 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 working on this! Some comments to get you started

/wait

- refactor `resolveReplicas` to resolve all the replicas in a loop, in parallel
- add docstrings for `resolveReplicas` and `resolveHostname`

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@huntsman90
Copy link
Copy Markdown
Contributor Author

Thanks for working on this! Some comments to get you started

/wait

Thanks for the review @snowp . I have incorporated all the suggestions. I've left a few comments/questions for the ones left unresolved.

NOTE: I'm not sure of the review-comment-resolve process here; so, apologies if me resolving the comments slows the review process for you.

Additionally, I have a question: It says that the branch has conflicts that need resolution. However, would rebasing on main branch cause problems with the review? (I read in the contributing guide to avoid rebasing until the review is complete, so unsure of the recommended steps here).

@huntsman90 huntsman90 requested a review from snowp January 19, 2022 07:05
@huntsman90
Copy link
Copy Markdown
Contributor Author

Additionally, I have a question: It says that the branch has conflicts that need resolution. However, would rebasing on main branch cause problems with the review? (I read in the contributing guide to avoid rebasing until the review is complete, so unsure of the recommended steps here).

I fixed this via a merge of main branch.

snowp
snowp previously requested changes Jan 24, 2022
Copy link
Copy Markdown
Contributor

@snowp snowp 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 working on this! Some high level comments, I would love to be able to simplify this code a little bit

@snowp
Copy link
Copy Markdown
Contributor

snowp commented Jan 24, 2022

Also FYI @mattklein123 since you're back now and Redis belongs to you :)

@snowp snowp added the waiting label Jan 28, 2022
@KBaichoo
Copy link
Copy Markdown
Contributor

PTAL @snowp to either take another pass, or hand off to codeowner

@snowp
Copy link
Copy Markdown
Contributor

snowp commented Feb 18, 2022

We've been talking over DM, I believe this one is still waiting for an integration test?

/wait

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@snowp
Copy link
Copy Markdown
Contributor

snowp commented Feb 18, 2022

@mattklein123 Can you keep an eye on this as I'll be out starting next week?

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@mattklein123 mattklein123 self-assigned this Feb 19, 2022
Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@huntsman90 huntsman90 requested a review from snowp February 19, 2022 01:01
@huntsman90
Copy link
Copy Markdown
Contributor Author

Hello! 👋 I've added the integrations test, and I believe the PR is ready for a review now. Please take a look when possible @mattklein123 . Thanks!

@mattklein123 mattklein123 dismissed snowp’s stale review February 22, 2022 17:18

taking over review, integration test added

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks generally this LGTM. In addition to my comment in the code, can you please also add a release note as well as update https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/other_protocols/redis.html to make it more clear that we now support this.

Thank you.

/wait

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
@huntsman90
Copy link
Copy Markdown
Contributor Author

@mattklein123 the PR is updated. Please recommend updates to the documentation added, if required.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 4ce48c4 into envoyproxy:main Feb 28, 2022
mattklein123 pushed a commit that referenced this pull request Mar 8, 2022
Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
JuniorHsu pushed a commit to JuniorHsu/envoy that referenced this pull request Mar 17, 2022
…voyproxy#20217)

Signed-off-by: Sai Teja Duthuluri <dsaiteja1908@gmail.com>
Signed-off-by: kuochunghsu <kuochunghsu@pinterest.com>
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.

Envoy + Encrypted Redis Cluster errors

8 participants