提交 c9389ee6 编写于 作者: D dlorenc 提交者: GitHub

Merge pull request #693 from dlorenc/service

Check to see if any endpoints are ready, instead of if any endpoints …
......@@ -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
......
......@@ -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")
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册