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

Password-protected Redis storage provider connection errors #1557

Closed
cadams93 opened this issue Feb 3, 2025 · 5 comments · Fixed by #1563
Closed

Password-protected Redis storage provider connection errors #1557

cadams93 opened this issue Feb 3, 2025 · 5 comments · Fixed by #1563
Assignees
Labels
confirmed bug The issue was replicated/determined to be a bug. internally-reviewed The issue has been reviewed internally.

Comments

@cadams93
Copy link

cadams93 commented Feb 3, 2025

Component(s)

router

router version

v0.170.0

What happened?

Description

The recent PR #1499 has introduced the ability to connect to Redis, when running in cluster-mode, which was previously unsupported. As a result of this change, it is my understanding that connecting to Redis clusters or indeed standalone instances with a password is no longer functioning correctly.

https://github.com/wundergraph/cosmo/pull/1499/files#diff-3173118cd9e8f3849a4d398d232609e32cac4991fd962e78280d9c68c14b67abR26 - NewRedisCloser is passed an options bundle, which never has Password populated (hence will be "").

  • For cluster_mode: false, the password parsed from the URL using the go-redis library is replaced by the value provided in this options struct.
  • For cluster_mode: true, the password is mapped into the go-redis library's ClusterOptions struct

In both cases, having an "" value will cause issues for connections requiring authentication, and result in a NOAUTH response from the Redis server.

Additionally TLS connections using the rediss:// URL scheme appear to be unsupported when using cluster_enabled: true. The manual stripping of the scheme from each URL strips only redis:// (non-TLS) URLs. Doing this outside of the go-redis library also neglects to configure the ClusterOptions.TLSConfig option, which results in a non-TLS connection being attempted to a TLS Redis instance, also failing.

fwiw: a symmetrical function to redis.ParseURL exists in the backing go-redis library, specifically for parsing cluster-mode URLs into the ClusterOptions struct, called redis.ParseClusterURL. If used, this would provide greater flexibility for consumers, allowing timeouts, connection pools, etc to be configured.

Steps to Reproduce

  • Scenario 1: Standalone Redis connections *
  1. Start a local Redis instance: docker run -p 6379:6379 redis
  2. Set a password on the instance, by connecting with redis-cli and running:
CONFIG SET requirepass "mypass"
  1. Configure Cosmo Router with a Redis storage provider:
#... 
 storage:
    cluster_enabled: false
    urls:
      - "redis://default:mypass@localhost:6379"
# ...
  1. Start Cosmo Router
  2. Notice error in logs:
failed to bootstrap router: failed to create a functioning redis client 
  • Scenario 2: Cluster mode Redis connections *
  1. Start a local Redis cluster-mode cluster, with a password of "mypass"
  2. Configure Cosmo Router with a Redis storage provider:
#... 
 storage:
    cluster_enabled: true
    urls:
      - "redis://default:mypass@localhost:6379"
      - "redis://default:mypass@localhost:6380"
      - "redis://default:mypass@localhost:6381"
# ...
  1. Start Cosmo Router
  2. Notice similar error in logs

(For the TLS issue, supply rediss:// as the scheme, and notice this is not stripped in the URLs supplied to the underlying library)

Expected Result

Connection to Redis cluster-mode and/or standalone instances over non-TLS and/or TLS connections, with the ability to supply a valid password.

Actual Result

  • failed to bootstrap router: failed to create a functioning redis client

Log output

failed to bootstrap router: failed to create a functioning redis client 
@cadams93 cadams93 added the bug Something isn't working label Feb 3, 2025
Copy link

github-actions bot commented Feb 3, 2025

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

@cadams93 cadams93 changed the title Redis storage provider connections Password-protected Redis storage provider connection errors Feb 3, 2025
@cadams93
Copy link
Author

cadams93 commented Feb 4, 2025

As mentioned in the original issue, this appears to be a regression for standalone password-protected Redis connections, as running v0.169.0 of router with equivalent config does not result in the same error and successfully connects:

#... 
 storage:
    url: "redis://default:mypass@localhost:6379"
# ...

@df-wg df-wg self-assigned this Feb 4, 2025
@df-wg df-wg added internally-reviewed The issue has been reviewed internally. confirmed bug The issue was replicated/determined to be a bug. labels Feb 4, 2025
@df-wg
Copy link
Contributor

df-wg commented Feb 4, 2025

@cadams93 Thank you for the extremely clear issue write up! I'm going to get a fix for this out ASAP

@Aenimus Aenimus removed the bug Something isn't working label Feb 4, 2025
@df-wg
Copy link
Contributor

df-wg commented Feb 5, 2025

Hey @cadams93 , we just released a fix in [email protected]. Let me know if that works for you!

@iDub79
Copy link

iDub79 commented Feb 7, 2025

Appreciate the quick turnaround @df-wg . I have tested the latest changes and it is now working for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug The issue was replicated/determined to be a bug. internally-reviewed The issue has been reviewed internally.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants