mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-24 23:30:20 +00:00
cephfs: update fetchIP to support ipv6 addresses
Signed-off-by: Riya Singhal <rsinghal@redhat.com>
This commit is contained in:
parent
304462c7cc
commit
0631c15025
@ -212,9 +212,12 @@ func (ac *activeClient) fetchIP() (string, error) {
|
|||||||
clientInfo := ac.Inst
|
clientInfo := ac.Inst
|
||||||
parts := strings.Fields(clientInfo)
|
parts := strings.Fields(clientInfo)
|
||||||
if len(parts) >= 2 {
|
if len(parts) >= 2 {
|
||||||
ip := strings.Split(parts[1], ":")[0]
|
lastColonIndex := strings.LastIndex(parts[1], ":")
|
||||||
|
firstPart := parts[1][:lastColonIndex]
|
||||||
return ip, nil
|
ip := net.ParseIP(firstPart)
|
||||||
|
if ip != nil {
|
||||||
|
return ip.String(), nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", fmt.Errorf("failed to extract IP address, incorrect format: %s", clientInfo)
|
return "", fmt.Errorf("failed to extract IP address, incorrect format: %s", clientInfo)
|
||||||
|
Loading…
Reference in New Issue
Block a user