Skip to content

Fix IPv6 gRPC address formatting in Medusa client connection#1680

Open
rajish wants to merge 3 commits intok8ssandra:mainfrom
rajish:fix/ipv6-medusa-grpc-address
Open

Fix IPv6 gRPC address formatting in Medusa client connection#1680
rajish wants to merge 3 commits intok8ssandra:mainfrom
rajish:fix/ipv6-medusa-grpc-address

Conversation

@rajish
Copy link
Copy Markdown

@rajish rajish commented Jan 28, 2026

Summary

Use net.JoinHostPort() instead of fmt.Sprintf() to correctly format IPv6 addresses when constructing the Medusa gRPC sidecar address in controllers/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:

invalid target address 2a05:d01c:ae4:ee06:1310::3:50051, error info: address 2a05:d01c:ae4:ee06:1310::3:50051:443: too many colons in address

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.Sprintfnet.JoinHostPort() in medusabackupjob_controller.go and medusatask_controller.go. When the gRPC client creation was later refactored into the shared newClient() function in common.go, the bug was reintroduced.

Fix

Replace fmt.Sprintf("%s:%d", ...) with net.JoinHostPort() which correctly handles both IPv4 and IPv6 addresses:

  • IPv4: 10.0.0.1:50051 (unchanged)
  • IPv6: [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

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
@rajish rajish requested a review from a team as a code owner January 28, 2026 18:47
@rajish rajish force-pushed the fix/ipv6-medusa-grpc-address branch from 2e2b190 to a51b686 Compare January 28, 2026 19:00
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.
@rajish rajish force-pushed the fix/ipv6-medusa-grpc-address branch from a51b686 to 557417c Compare January 28, 2026 19:07
@sonarqubecloud
Copy link
Copy Markdown

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.

Support EKS/K8S Only IPv6 operator can't talk to medusa sidecar in ipv6 only environment

1 participant