Merge pull request #83104 from zouyee/gfs

IP validates if a string is a valid IP address
This commit is contained in:
Kubernetes Prow Robot
2019-10-07 03:13:08 -07:00
committed by GitHub

View File

@@ -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)