Merge pull request #9155 from cjcullen/mig

Use Node IP Address instead of Node.Name in minion.ResourceLocation.
This commit is contained in:
Brian Grant
2015-06-02 22:51:20 -07:00
5 changed files with 47 additions and 30 deletions

View File

@@ -33,6 +33,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
nodeutil "github.com/GoogleCloudPlatform/kubernetes/pkg/util/node"
)
// nodeStrategy implements behavior for nodes
@@ -141,13 +142,16 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet
return nil, nil, err
}
node := nodeObj.(*api.Node)
host := node.Name // TODO: use node's IP, don't expect the name to resolve.
if portReq != "" {
return &url.URL{Host: net.JoinHostPort(host, portReq)}, nil, nil
hostIP, err := nodeutil.GetNodeHostIP(node)
if err != nil {
return nil, nil, err
}
scheme, port, transport, err := connection.GetConnectionInfo(host)
if portReq != "" {
return &url.URL{Host: net.JoinHostPort(hostIP.String(), portReq)}, nil, nil
}
scheme, port, transport, err := connection.GetConnectionInfo(hostIP.String())
if err != nil {
return nil, nil, err
}
@@ -155,7 +159,7 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet
return &url.URL{
Scheme: scheme,
Host: net.JoinHostPort(
host,
hostIP.String(),
strconv.FormatUint(uint64(port), 10),
),
},