Fix IPv6 gRPC address formatting in Medusa client connection#1680
Open
rajish wants to merge 3 commits intok8ssandra:mainfrom
Open
Fix IPv6 gRPC address formatting in Medusa client connection#1680rajish wants to merge 3 commits intok8ssandra:mainfrom
rajish wants to merge 3 commits intok8ssandra:mainfrom
Conversation
Use net.JoinHostPort() instead of fmt.Sprintf to correctly format IPv6 addresses with brackets when constructing the Medusa gRPC sidecar address. Without this fix, IPv6 addresses like 2a05:d01c:ae4:ee06::3 are formatted as '2a05:d01c:ae4:ee06::3:50051' which causes 'too many colons in address' errors. The correct format is '[2a05:d01c:ae4:ee06::3]:50051'. This is a regression of the fix in PR k8ssandra#871, which was lost when the gRPC client creation was refactored into the shared newClient() function in common.go. Fixes k8ssandra#967 Fixes k8ssandra#870
2e2b190 to
a51b686
Compare
Tests verify that newClient() correctly formats the gRPC address for: - IPv4 addresses: 192.168.1.10:50051 - IPv6 addresses: [2a05:d01c:ae4:ee06:1310::3]:50051 - IPv6 loopback: [::1]:50051 This prevents a repeat of the regression where fmt.Sprintf was used instead of net.JoinHostPort after code refactoring.
a51b686 to
557417c
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.



Summary
Use
net.JoinHostPort()instead offmt.Sprintf()to correctly format IPv6 addresses when constructing the Medusa gRPC sidecar address incontrollers/medusa/common.go.Problem
In IPv6-only environments (e.g., EKS with IPv6-only networking), the operator fails to connect to the Medusa gRPC sidecar with:
The current code uses
fmt.Sprintf("%s:%d", pod.Status.PodIP, grpcPort)which produces<ipv6>:<port>instead of the required[<ipv6>]:<port>format.Root Cause
This is a regression of the fix in PR #871, which correctly changed
fmt.Sprintf→net.JoinHostPort()inmedusabackupjob_controller.goandmedusatask_controller.go. When the gRPC client creation was later refactored into the sharednewClient()function incommon.go, the bug was reintroduced.Fix
Replace
fmt.Sprintf("%s:%d", ...)withnet.JoinHostPort()which correctly handles both IPv4 and IPv6 addresses:10.0.0.1:50051(unchanged)[2a05:d01c:ae4:ee06::3]:50051(brackets added)Testing
Verified on an IPv6-only EKS cluster (v1.33) running K8ssandra operator v1.30.2 with Cassandra 4.1.3 and Medusa 0.27.0.
Fixes #967
Fixes #870