mirror of
https://github.com/coredns/coredns.git
synced 2025-11-23 20:24:02 -05:00
plugin/health: implement dyn health checks (#1214)
Implement health.Healther in erratic and kubernetes plugin. The kubernetes' healtcheck is only performed on startup - i.e. turn healthy after the initial loading. Erratic follow the drop count: every query%drop turns the healthcheck unhealthy. Fixes: #985
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
package health
|
||||
|
||||
// TODO(miek): enable again if plugin gets health check.
|
||||
/*
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin/erratic"
|
||||
)
|
||||
|
||||
func TestHealth(t *testing.T) {
|
||||
h := health{Addr: ":0"}
|
||||
h.h = append(h.h, &erratic.Erratic{})
|
||||
@@ -14,7 +21,7 @@ func TestHealth(t *testing.T) {
|
||||
// Reconstruct the http address based on the port allocated by operating system.
|
||||
address := fmt.Sprintf("http://%s%s", h.ln.Addr().String(), path)
|
||||
|
||||
// Norhing set should be unhealthy
|
||||
// Nothing set should return unhealthy
|
||||
response, err := http.Get(address)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to query %s: %v", address, err)
|
||||
@@ -24,8 +31,7 @@ func TestHealth(t *testing.T) {
|
||||
}
|
||||
response.Body.Close()
|
||||
|
||||
// Make healthy
|
||||
h.Poll()
|
||||
h.poll()
|
||||
|
||||
response, err = http.Get(address)
|
||||
if err != nil {
|
||||
@@ -44,4 +50,3 @@ func TestHealth(t *testing.T) {
|
||||
t.Errorf("Invalid response body: expecting 'OK', got '%s'", string(content))
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user