mirror of
https://github.com/coredns/coredns.git
synced 2025-11-27 06:04:03 -05:00
plugin/health: remove ability to poll other plugins (#2547)
* plugin/health: remove ability to poll other plugins This mechanism defeats the purpose any plugin (mostly) caching can still be alive, we can probably forward queries still. Don't poll plugins, just tell the world we're up and running. It was only actually used in kubernetes; and there specifically would mean any network hiccup would NACK the entire server health. Fixes: #2534 Signed-off-by: Miek Gieben <miek@miek.nl> * update docs based on feedback Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -6,43 +6,23 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/plugin/erratic"
|
||||
)
|
||||
|
||||
func TestHealth(t *testing.T) {
|
||||
h := newHealth(":0")
|
||||
h.h = append(h.h, &erratic.Erratic{})
|
||||
|
||||
if err := h.OnStartup(); err != nil {
|
||||
t.Fatalf("Unable to startup the health server: %v", err)
|
||||
}
|
||||
defer h.OnFinalShutdown()
|
||||
|
||||
go func() {
|
||||
<-h.pollstop
|
||||
return
|
||||
}()
|
||||
|
||||
// Reconstruct the http address based on the port allocated by operating system.
|
||||
address := fmt.Sprintf("http://%s%s", h.ln.Addr().String(), path)
|
||||
|
||||
// Nothing set should return unhealthy
|
||||
response, err := http.Get(address)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to query %s: %v", address, err)
|
||||
}
|
||||
if response.StatusCode != 503 {
|
||||
t.Errorf("Invalid status code: expecting '503', got '%d'", response.StatusCode)
|
||||
}
|
||||
response.Body.Close()
|
||||
|
||||
h.poll()
|
||||
|
||||
response, err = http.Get(address)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to query %s: %v", address, err)
|
||||
}
|
||||
if response.StatusCode != 200 {
|
||||
t.Errorf("Invalid status code: expecting '200', got '%d'", response.StatusCode)
|
||||
}
|
||||
@@ -60,18 +40,10 @@ func TestHealth(t *testing.T) {
|
||||
func TestHealthLameduck(t *testing.T) {
|
||||
h := newHealth(":0")
|
||||
h.lameduck = 250 * time.Millisecond
|
||||
h.h = append(h.h, &erratic.Erratic{})
|
||||
|
||||
if err := h.OnStartup(); err != nil {
|
||||
t.Fatalf("Unable to startup the health server: %v", err)
|
||||
}
|
||||
|
||||
// Both these things are behind a sync.Once, fake reading from the channels.
|
||||
go func() {
|
||||
<-h.pollstop
|
||||
<-h.stop
|
||||
return
|
||||
}()
|
||||
|
||||
h.OnFinalShutdown()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user