Skip to content

Commit 708ba29

Browse files
committed
utils: test the escaped colons of an IPv6 Ceph monitor without a port
composeOptionForMonHosts escapes every ':' of a monitor, because the colons separate the options of the rbd: string. That includes the colons of an IPv6 address, also when the pool has no port to add. Test that case, and make addPortToRbdMonitor, which is only used by RbdUtils itself, protected.
1 parent 1f3f501 commit 708ba29

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎utils/src/main/java/com/cloud/utils/RbdUtils.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static String getRbdMonitors(String sourceHost, int sourcePort) {
4646
return String.join(",", monitors);
4747
}
4848

49-
public static String addPortToRbdMonitor(String monitor, int port) {
49+
protected static String addPortToRbdMonitor(String monitor, int port) {
5050
if (monitor.startsWith("[")) {
5151
// IPv6 address in square brackets, which has a port if followed by ":<port>"
5252
return monitor.contains("]:") ? monitor : monitor + ":" + port;

‎utils/src/test/java/com/cloud/utils/RbdUtilsTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public void testComposeOptionForMonHostsEscapesEveryColonOfAnIpv6Monitor() {
119119
@Test
120120
public void testComposeOptionForMonHostsWithoutAPortLeavesTheMonitorAlone() {
121121
assertEquals("ceph-monitor", RbdUtils.composeOptionForMonHosts("ceph-monitor", 0));
122+
assertEquals("fd00\\:\\:1", RbdUtils.composeOptionForMonHosts("fd00::1", 0));
122123
}
123124

124125
@Test

0 commit comments

Comments
 (0)