Merge pull request #693 from dlorenc/service
Check to see if any endpoints are ready, instead of if any endpoints …pull/648/head
commit
c9389ee6fa
|
@ -108,9 +108,9 @@ func CheckEndpointReady(endpoint *kubeApi.Endpoints) error {
|
||||||
return errors.New("Endpoint for service is not ready yet")
|
return errors.New("Endpoint for service is not ready yet")
|
||||||
}
|
}
|
||||||
for _, subset := range endpoint.Subsets {
|
for _, subset := range endpoint.Subsets {
|
||||||
if len(subset.NotReadyAddresses) != 0 {
|
if len(subset.Addresses) == 0 {
|
||||||
fmt.Fprintf(os.Stderr, notReadyMsg)
|
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
|
return nil
|
||||||
|
|
|
@ -30,14 +30,14 @@ func TestCheckEndpointReady(t *testing.T) {
|
||||||
|
|
||||||
endpointNotReady := &kubeApi.Endpoints{
|
endpointNotReady := &kubeApi.Endpoints{
|
||||||
Subsets: []kubeApi.EndpointSubset{
|
Subsets: []kubeApi.EndpointSubset{
|
||||||
{Addresses: []kubeApi.EndpointAddress{
|
{Addresses: []kubeApi.EndpointAddress{},
|
||||||
{IP: "1.1.1.1"},
|
|
||||||
{IP: "2.2.2.2"}},
|
|
||||||
NotReadyAddresses: []kubeApi.EndpointAddress{
|
NotReadyAddresses: []kubeApi.EndpointAddress{
|
||||||
|
{IP: "1.1.1.1"},
|
||||||
|
{IP: "2.2.2.2"},
|
||||||
{IP: "3.3.3.3"},
|
{IP: "3.3.3.3"},
|
||||||
}}}}
|
}}}}
|
||||||
if err := CheckEndpointReady(endpointNotReady); err == nil {
|
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{
|
endpointReady := &kubeApi.Endpoints{
|
||||||
|
@ -50,6 +50,6 @@ func TestCheckEndpointReady(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
if err := CheckEndpointReady(endpointReady); err != nil {
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue