Skip to content

Commit

Permalink
core: return valid CIDR ip
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit eb304a5)
  • Loading branch information
Madhu-1 authored and subhamkrai committed Aug 29, 2023
1 parent 408a5f6 commit d35fa1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/operator/ceph/cluster/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/ceph/cluster/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d35fa1a

Please sign in to comment.