kubectl-ceph-rook: Monitor endpoint parsing fails with IPv6 addresses · Issue #367 · rook/kubectl-rook-ceph · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The kubectl-ceph-rook plugin fails to correctly parse IPv6 monitor endpoints, causing commands like mons restore-quorum to fail when working with Ceph clusters configured with IPv6 addresses.
Current Behavior
When running kubectl rook-ceph mons restore-quorum with IPv6 monitor addresses, the command fails with an error:
Info: mon=a, endpoints=[2a02:5501:31:c0a::3]:6789
Info: mon=b, endpoints=[2a02:5501:31:c0a::4]:6789
...
Info: Restoring mon quorum to mon b [2a02
...
parse error setting 'public_addr' to '[2a02'
too many arguments: [--setuser-match-path=/var/lib/ceph/mon/ceph-b/store.db]
Error: failed to run command. failed to run command. command terminated with exit code 1
%!(EXTRA string=failed to extract monmap)
The issue occurs in the getMonDetails() function, which uses a simple string split by the first colon to extract the IP address and port from monitor endpoints:
This approach works for IPv4 addresses (e.g., 192.168.1.1:6789), but fails for IPv6 addresses (e.g., [2a02:5501:31:c0a::3]:6789) because IPv6 addresses themselves contain colons.
Expected Behavior
The getMonDetails() function should correctly parse both IPv4 and IPv6 monitor endpoints, extracting the proper IP address and port in both cases.
Proposed Solution
The getMonDetails() function needs to be enhanced to handle IPv6 addresses. A possible solution is to check if the endpoint contains more than one colon (indicating a possible IPv6 address) and use the last colon as the separator between the IP address and port for IPv6 addresses:
Problem Description
The
kubectl-ceph-rook
plugin fails to correctly parse IPv6 monitor endpoints, causing commands likemons restore-quorum
to fail when working with Ceph clusters configured with IPv6 addresses.Current Behavior
When running
kubectl rook-ceph mons restore-quorum
with IPv6 monitor addresses, the command fails with an error:The issue occurs in the
getMonDetails()
function, which uses a simple string split by the first colon to extract the IP address and port from monitor endpoints:This approach works for IPv4 addresses (e.g.,
192.168.1.1:6789
), but fails for IPv6 addresses (e.g.,[2a02:5501:31:c0a::3]:6789
) because IPv6 addresses themselves contain colons.Expected Behavior
The
getMonDetails()
function should correctly parse both IPv4 and IPv6 monitor endpoints, extracting the proper IP address and port in both cases.Proposed Solution
The
getMonDetails()
function needs to be enhanced to handle IPv6 addresses. A possible solution is to check if the endpoint contains more than one colon (indicating a possible IPv6 address) and use the last colon as the separator between the IP address and port for IPv6 addresses:This approach would correctly handle both IPv4 and IPv6 addresses without breaking existing functionality.
Fix Implementation
I've submitted a pull request that implements the proposed solution:
PR #366: kubectl-ceph-rook: Fix IPv6 address handling in monitor endpoint parsing
The text was updated successfully, but these errors were encountered: