Change Redis cluster port mapping to work on mac#1061
Open
kowser-orkes wants to merge 2 commits intomainfrom
Open
Change Redis cluster port mapping to work on mac#1061kowser-orkes wants to merge 2 commits intomainfrom
kowser-orkes wants to merge 2 commits intomainfrom
Conversation
23aacea to
0acb831
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request type
NOTE: Please remember to run
./gradlew spotlessApplyto fix any format violations.Changes in this PR
JedisClusterCommandsBatchTestwas failing withJedisClusterOperationException: Cluster retry deadline exceeded/SocketTimeoutException: Read timed outbecause of a Redis Cluster port-mapping mismatch.The test maps container ports 7000–7005 to host ports 17000–17005 to avoid a conflict with macOS Control Center, which permanently occupies port 7000 on macOS (it registers as
afs3-fileserver). However, Redis Cluster nodes advertise their own address to clients via the cluster topology (MOVED redirects), and the container's nodes announce themselves on their internal ports (7000–7005). When Jedis followed a redirect to127.0.0.1:7000, that port was not open on the host, causing every connection attempt to time out.Fix: pass a
HostAndPortMapperinDefaultJedisClientConfigwhen constructingJedisCluster. The mapper intercepts every address returned by the cluster topology and shifts ports 7000–7005 → 17000–17005, so Jedis always connects through the exposed host ports.Issue #
Alternatives considered
Map container ports 7000→7000 (original setup): Fails on macOS because Control Center permanently occupies port 7000 (
afs3-fileserver). This is a macOS system process that cannot be stopped, so the original mapping is not viable on developer machines running macOS.Use Testcontainers' dynamic port assignment: Would avoid fixed-port conflicts entirely, but requires the Redis cluster image to support runtime
cluster-announce-portconfiguration (injected as env vars at startup). The currentorkesio/redis-clusterimage does not expose that knob, so this would need an image change.