From d35fa1a37bd35460350be5b4e5075a16f59aa4f4 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 28 Aug 2023 10:46:27 +0200 Subject: [PATCH] core: return valid CIDR ip we need to return a valid CIDR IP to get it fenced properly, the previously returned one was like `10.63.0.5:0/32` which is not a valid CIDR, removing `:0` to look like proper IP CIDR. Signed-off-by: Madhu Rajanna (cherry picked from commit eb304a50739cd4aeec5c4fc11f0e10910cac310d) --- pkg/operator/ceph/cluster/watcher.go | 5 +++-- pkg/operator/ceph/cluster/watcher_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/operator/ceph/cluster/watcher.go b/pkg/operator/ceph/cluster/watcher.go index 722642412d38..f04e5353de85 100644 --- a/pkg/operator/ceph/cluster/watcher.go +++ b/pkg/operator/ceph/cluster/watcher.go @@ -350,8 +350,9 @@ func rbdStatusUnMarshal(output []byte) ([]string, error) { } func concatenateWatcherIp(address string) string { - // split with separation '/' to remove nounce and concatenating `/32` to define a network with only one IP address - watcherIP := strings.Split(address, "/")[0] + "/32" + // address is in format `10.63.0.5:0/1254753579` + // split with separation ':0/' to remove nounce and concatenating `/32` to define a network with only one IP address + watcherIP := strings.Split(address, ":0/")[0] + "/32" return watcherIP } diff --git a/pkg/operator/ceph/cluster/watcher_test.go b/pkg/operator/ceph/cluster/watcher_test.go index 2339559c74af..2a28d755f1ea 100644 --- a/pkg/operator/ceph/cluster/watcher_test.go +++ b/pkg/operator/ceph/cluster/watcher_test.go @@ -348,12 +348,12 @@ func TestRBDStatusUnMarshal(t *testing.T) { listIP, err := rbdStatusUnMarshal([]byte(output)) assert.NoError(t, err) - assert.Equal(t, listIP[0], "192.168.39.137:0/32") + assert.Equal(t, listIP[0], "192.168.39.137/32") } func TestConcatenateWatcherIp(t *testing.T) { WatcherIP := concatenateWatcherIp("192.168.39.137:0/3762982934") - assert.Equal(t, WatcherIP, "192.168.39.137:0/32") + assert.Equal(t, WatcherIP, "192.168.39.137/32") } func TestOnDeviceCMUpdate(t *testing.T) {