Validate external names

This commit is contained in:
Manuel de Brito Fontes 2017-09-24 17:36:59 -03:00
parent 27d4e8b3d5
commit f8b213cbea

View file

@ -19,6 +19,7 @@ package controller
import (
"fmt"
"math/rand"
"net"
"reflect"
"sort"
"strconv"
@ -1090,6 +1091,14 @@ func (ic *GenericController) getEndpoints(
return upsServers
}
if net.ParseIP(s.Spec.ExternalName) == nil {
_, err := net.LookupHost(s.Spec.ExternalName)
if err != nil {
glog.Errorf("unexpected error resolving host %v: %v", s.Spec.ExternalName, err)
return upsServers
}
}
return append(upsServers, ingress.Endpoint{
Address: s.Spec.ExternalName,
Port: fmt.Sprintf("%v", targetPort),