Merge pull request #16490 from rook/mergify/bp/release-1.18/pr-16468

external: fix ipv6 monitoring endpoint reconcile (backport #16468)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2025-09-15 13:47:43 -06:00
commit ccbac6de98
2 files changed
+23 -1

No files matched your search

+7 -1
View File
@@ -21,6 +21,7 @@ import (
"context"
"encoding/binary"
"fmt"
"net"
"os"
"path"
"reflect"
@@ -954,7 +955,12 @@ func ConfigureExternalMetricsEndpoint(ctx *clusterd.Context, monitoringSpec ceph
}
func extractMgrIP(rawActiveAddr string) string {
return strings.Split(rawActiveAddr, ":")[0]
host, _, err := net.SplitHostPort(rawActiveAddr)
if err != nil {
// If there's no port, return as is
return rawActiveAddr
}
return host
}
func GetContainerImagePullPolicy(containerImagePullPolicy v1.PullPolicy) v1.PullPolicy {
+16
View File
@@ -259,6 +259,22 @@ func TestExtractMgrIP(t *testing.T) {
activeMgrRaw := "172.17.0.12:6801/2535462469"
ip := extractMgrIP(activeMgrRaw)
assert.Equal(t, "172.17.0.12", ip)
activeMgrRaw = "[2001:db8::1]:6801/2535462469"
ip = extractMgrIP(activeMgrRaw)
assert.Equal(t, "2001:db8::1", ip)
activeMgrRaw = "invalid-address"
ip = extractMgrIP(activeMgrRaw)
assert.Equal(t, activeMgrRaw, ip)
activeMgrRaw = ""
ip = extractMgrIP(activeMgrRaw)
assert.Equal(t, "", ip)
activeMgrRaw = "172.17.0.12"
ip = extractMgrIP(activeMgrRaw)
assert.Equal(t, activeMgrRaw, ip)
}
func TestConfigureExternalMetricsEndpoint(t *testing.T) {