From e15bc28967e70841ceff43442d1066cd87c775b0 Mon Sep 17 00:00:00 2001 From: Wayne Song Date: Mon, 28 Nov 2016 09:23:51 -0800 Subject: [PATCH] Don't forward _ping requests to the primary Signed-off-by: Wayne Song --- api/replica.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/replica.go b/api/replica.go index 36ad027de0..2bb8612574 100644 --- a/api/replica.go +++ b/api/replica.go @@ -7,7 +7,7 @@ import ( "strings" ) -var localRoutes = []string{"/_ping", "/info", "/debug"} +var localRoutes = []string{"/info", "/debug"} // Replica is an API replica that reserves proxy to the primary. type Replica struct { @@ -46,6 +46,13 @@ func (p *Replica) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + // We also handle /_ping locally, but we do so after the primary + // check above. + if strings.HasSuffix(r.URL.Path, "/_ping") { + w.Write([]byte("OK")) + return + } + if err := hijack(p.tlsConfig, p.primary, w, r); err != nil { httpError(w, fmt.Sprintf("Unable to reach primary cluster manager (%s): %v", err, p.primary), http.StatusInternalServerError) }