Add v1.NodeLegacyHostIP to be consistent with the internal API;

Mark NodeLegacyHostIP will be deprecated in 1.7;
Let cloudprovider that used to only set NodeLegacyHostIP set the IP as both InternalIP and ExternalIP, to allow dprecation in 1.7
This commit is contained in:
Chao Xu
2016-11-02 13:48:27 -07:00
parent 8e3909c32a
commit 783af943db
8 changed files with 29 additions and 48 deletions

View File

@@ -167,29 +167,6 @@ func TestVersion(t *testing.T) {
}
}
// TestFindExternalAddress verifies both pass and fail cases for the unexported
// findExternalAddress function
func TestFindExternalAddress(t *testing.T) {
assert := assert.New(t)
expectedIP := "172.0.0.1"
nodes := []*api.Node{new(api.Node), new(api.Node), new(api.Node)}
nodes[0].Status.Addresses = []api.NodeAddress{{Type: "ExternalIP", Address: expectedIP}}
nodes[1].Status.Addresses = []api.NodeAddress{{Type: "LegacyHostIP", Address: expectedIP}}
nodes[2].Status.Addresses = []api.NodeAddress{{Type: "ExternalIP", Address: expectedIP}, {Type: "LegacyHostIP", Address: "172.0.0.2"}}
// Pass Case
for _, node := range nodes {
ip, err := findExternalAddress(node)
assert.NoError(err, "error getting node external address")
assert.Equal(expectedIP, ip, "expected ip to be %s, but was %s", expectedIP, ip)
}
// Fail case
_, err := findExternalAddress(new(api.Node))
assert.Error(err, "expected findExternalAddress to fail on a node with missing ip information")
}
type fakeEndpointReconciler struct{}
func (*fakeEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []api.EndpointPort, reconcilePorts bool) error {