Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2235395: core: return valid CIDR ip #515

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading