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

Redis: Fix invalid cluster client initialization option #1252

Merged

Conversation

rinx
Copy link
Contributor

@rinx rinx commented May 24, 2021

Description:

In the current code, on Redis cluster client initialization,

c = redis.NewClusterClient(&redis.ClusterOptions{
Addrs: rc.addrs,
NewClient: func(opt *redis.Options) *redis.Client {
c, err := rc.newClient(ctx)
if err != nil {
return redis.NewClient(opt)
}
return c
},

the opt argument of the NewClient option is ignored when rc.newClient(ctx) returns no error. However, it is important to use opt for client initialization because opt.Addr is passed when a new clusterNode instance is created.
https://github.com/go-redis/redis/blob/f83600d1a5ac092f27dc672b9dda7cf7adde8bc1/cluster.go#L176-L189

So here, remove the invalid initialization code to fix the problem that occurs when Redis cluster is used.

Related Issue:

Nothing

How Has This Been Tested?:

Local cluster.

Environment:

  • Go Version: 1.16.4
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.12.3

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 💌 /changelog - replace the PR body by changelog details
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • /rebase - rebase master
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

@codecov
Copy link

codecov bot commented May 24, 2021

Codecov Report

Merging #1252 (c946550) into master (5a66d20) will decrease coverage by 0.44%.
The diff coverage is n/a.

❗ Current head c946550 differs from pull request most recent head 49751e5. Consider uploading reports for the commit 49751e5 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1252      +/-   ##
==========================================
- Coverage   17.98%   17.54%   -0.45%     
==========================================
  Files         501      498       -3     
  Lines       31465    30966     -499     
==========================================
- Hits         5660     5433     -227     
+ Misses      25511    25256     -255     
+ Partials      294      277      -17     
Impacted Files Coverage Δ
internal/db/kvs/redis/redis.go 58.87% <ø> (+11.70%) ⬆️
internal/worker/worker.go 82.29% <0.00%> (ø)
internal/net/grpc/client.go 0.00% <0.00%> (ø)
internal/client/v1/client/vald/vald.go 0.00% <0.00%> (ø)
internal/client/v1/client/agent/core/client.go 0.00% <0.00%> (ø)
internal/net/option.go
internal/net/net.go
internal/net/dialer.go
internal/errgroup/group.go 93.93% <0.00%> (+1.51%) ⬆️

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 5a66d20...49751e5. Read the comment docs.

@rinx rinx changed the title [WIP] Redis: Fix invalid cluster client initialization option Redis: Fix invalid cluster client initialization option May 24, 2021
@rinx rinx marked this pull request as ready for review May 24, 2021 07:39
@rinx rinx requested review from kpango and vankichi May 24, 2021 07:39
Copy link
Collaborator

@kpango kpango left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vankichi vankichi left a comment

Choose a reason for hiding this comment

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

THX :)

@kpango kpango merged commit a7452e4 into master May 25, 2021
@kpango kpango deleted the fix/meta-redis/fix-invalid-cluster-client-initialization branch May 25, 2021 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants