Skip to content

Commit 57593e1

Browse files
SkalaNetworksmergify[bot]
authored andcommitted
fix(controller): ipv6 addresses were unsupported by the controller
Signed-off-by: SkalaNetworks <[email protected]>
1 parent 509ea1a commit 57593e1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/controller/csiaddons/csiaddonsnode_controller.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,15 @@ func (r *CSIAddonsNodeReconciler) resolveEndpoint(ctx context.Context, rawURL st
346346
return podname, "", fmt.Errorf("pod %s/%s does not have an IP-address", namespace, podname)
347347
}
348348

349-
return podname, fmt.Sprintf("%s:%s", pod.Status.PodIP, port), nil
349+
ip := pod.Status.PodIP
350+
351+
// Detect if the IP has more than one colon in it, indicating an IPv6
352+
// We need this check to format it correctly, as we will append a port to the IP
353+
if strings.Count(ip, ":") >= 2 {
354+
ip = fmt.Sprintf("[%s]", ip)
355+
}
356+
357+
return podname, fmt.Sprintf("%s:%s", ip, port), nil
350358
}
351359

352360
// parseEndpoint returns the rawURL if it is in the legacy <IP-address>:<port>

0 commit comments

Comments
 (0)