From d77efbd71619670b8ee1b39fe8a276a339474b4e Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 2 Jul 2015 17:49:35 -0700 Subject: [PATCH] http: support ?standbyok for 200 status on standby. Fixes #389 --- CHANGELOG.md | 1 + http/sys_health.go | 5 ++++- website/source/docs/http/sys-health.html.md | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0998fd1e4..a6f7ee972b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ IMPROVEMENTS: * credential/ldap: Allow TLS verification to be disabled [GH-372] * credential/ldap: More flexible names allowed [GH-245] [GH-379] [GH-367] * http: response codes improved to reflect error [GH-366] + * http: the `sys/health` endpoint supports `?standbyok` to return 200 on standby [GH-389] * secret/app-id: Support deleting AppID and UserIDs [GH-200] * secret/consul: Fine grained lease control [GH-261] * secret/transit: Decouple raw key from key management endpoint [GH-355] diff --git a/http/sys_health.go b/http/sys_health.go index 8a53d1889d..e23905ba86 100644 --- a/http/sys_health.go +++ b/http/sys_health.go @@ -19,6 +19,9 @@ func handleSysHealth(core *vault.Core) http.Handler { } func handleSysHealthGet(core *vault.Core, w http.ResponseWriter, r *http.Request) { + // Check if being a standby is allowed for the purpose of a 200 OK + _, standbyOK := r.URL.Query()["standbyok"] + // Check system status sealed, _ := core.Sealed() standby, _ := core.Standby() @@ -35,7 +38,7 @@ func handleSysHealthGet(core *vault.Core, w http.ResponseWriter, r *http.Request code = http.StatusInternalServerError case sealed: code = http.StatusInternalServerError - case standby: + case !standbyOK && standby: code = 429 // Consul warning code } diff --git a/website/source/docs/http/sys-health.html.md b/website/source/docs/http/sys-health.html.md index f41eb931ed..80e2d2b819 100644 --- a/website/source/docs/http/sys-health.html.md +++ b/website/source/docs/http/sys-health.html.md @@ -20,7 +20,14 @@ description: |-
Parameters
- None +
Returns