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 <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna committed 2023-08-28 10:58:16 +02:00
1 parent 12023cf72e
commit eb304a5073
2 files changed
+5 -4

No files matched your search

+3 -2
View File
@@ -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
}
+2 -2
View File
@@ -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) {