Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Don't forward _ping requests to the primary #2554

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion api/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down