mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
IP validates if a string is a valid IP address
Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
parent
77d0ebe39f
commit
599fa5583e
@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -29,7 +30,7 @@ import (
|
||||
|
||||
gcli "github.com/heketi/heketi/client/api/go-client"
|
||||
gapi "github.com/heketi/heketi/pkg/glusterfs/api"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -968,6 +969,11 @@ func getClusterNodes(cli *gcli.Client, cluster string) (dynamicHostIps []string,
|
||||
return nil, fmt.Errorf("failed to get host ipaddress: %v", err)
|
||||
}
|
||||
ipaddr := dstrings.Join(nodeInfo.NodeAddRequest.Hostnames.Storage, "")
|
||||
// IP validates if a string is a valid IP address.
|
||||
ip := net.ParseIP(ipaddr)
|
||||
if ip == nil {
|
||||
return nil, fmt.Errorf("glusterfs server node ip address %s must be a valid IP address, (e.g. 10.9.8.7)", ipaddr)
|
||||
}
|
||||
dynamicHostIps = append(dynamicHostIps, ipaddr)
|
||||
}
|
||||
klog.V(3).Infof("host list :%v", dynamicHostIps)
|
||||
|
Loading…
Reference in New Issue
Block a user