Skip to content

Commit

Permalink
cephfs: update fetchIP to support ipv6 addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Singhal <[email protected]>
  • Loading branch information
riya-singhal31 authored and mergify[bot] committed Nov 8, 2023
1 parent 304462c commit 0631c15
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/csi-addons/networkfence/fencing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0631c15

Please sign in to comment.