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:
2 files changed
+23
-1
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user