Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cephfs: update fetchIP to support ipv6 addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Singhal <rsinghal@redhat.com>
riya-singhal31 committed Nov 8, 2023
1 parent 304462c commit bb355e3
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
@@ -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)

0 comments on commit bb355e3

Please sign in to comment.