Merge pull request #693 from dlorenc/service

Check to see if any endpoints are ready, instead of if any endpoints …
pull/648/head
dlorenc 2016-10-13 13:45:11 -07:00 committed by GitHub
commit c9389ee6fa
2 changed files with 7 additions and 7 deletions

View File

@ -108,9 +108,9 @@ func CheckEndpointReady(endpoint *kubeApi.Endpoints) error {
return errors.New("Endpoint for service is not ready yet")
}
for _, subset := range endpoint.Subsets {
if len(subset.NotReadyAddresses) != 0 {
if len(subset.Addresses) == 0 {
fmt.Fprintf(os.Stderr, notReadyMsg)
return errors.New("Endpoint for service is not ready yet")
return errors.New("No endpoints for service are ready yet")
}
}
return nil

View File

@ -30,14 +30,14 @@ func TestCheckEndpointReady(t *testing.T) {
endpointNotReady := &kubeApi.Endpoints{
Subsets: []kubeApi.EndpointSubset{
{Addresses: []kubeApi.EndpointAddress{
{IP: "1.1.1.1"},
{IP: "2.2.2.2"}},
{Addresses: []kubeApi.EndpointAddress{},
NotReadyAddresses: []kubeApi.EndpointAddress{
{IP: "1.1.1.1"},
{IP: "2.2.2.2"},
{IP: "3.3.3.3"},
}}}}
if err := CheckEndpointReady(endpointNotReady); err == nil {
t.Fatalf("Endpoint had NotReadyAddresses but CheckEndpointReady did not return an error")
t.Fatalf("Endpoint had no Addresses but CheckEndpointReady did not return an error")
}
endpointReady := &kubeApi.Endpoints{
@ -50,6 +50,6 @@ func TestCheckEndpointReady(t *testing.T) {
}},
}
if err := CheckEndpointReady(endpointReady); err != nil {
t.Fatalf("Endpoint was ready with no NotReadyAddresses but CheckEndpointReady returned an error")
t.Fatalf("Endpoint was ready with at least one Address, but CheckEndpointReady returned an error")
}
}