mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +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
|
||||
parts := strings.Fields(clientInfo)
|
||||
if len(parts) >= 2 {
|
||||
ip := strings.Split(parts[1], ":")[0]
|
||||
|
||||
return ip, nil
|
||||
lastColonIndex := strings.LastIndex(parts[1], ":")
|
||||
firstPart := parts[1][:lastColonIndex]
|
||||
ip := net.ParseIP(firstPart)
|
||||
if ip != nil {
|
||||
return ip.String(), nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("failed to extract IP address, incorrect format: %s", clientInfo)
|
||||
|
Loading…
Reference in New Issue
Block a user