Skip to content

Commit

Permalink
http: support ?standbyok for 200 status on standby. Fixes #389
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Jul 3, 2015
1 parent c3a6d90 commit d77efbd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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]
Expand Down
5 changes: 4 additions & 1 deletion http/sys_health.go
Expand Up @@ -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()
Expand All @@ -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
}

Expand Down
9 changes: 8 additions & 1 deletion website/source/docs/http/sys-health.html.md
Expand Up @@ -20,7 +20,14 @@ description: |-

<dt>Parameters</dt>
<dd>
None
<ul>
<li>
<span class="param">standbyok</span>
<span class="param-flags">optional</span>
A query parameter provided to indicate that being a standby should
still return a 200 status code instead of the standard 429 status code.
</li>
</ul>
</dd>

<dt>Returns</dt>
Expand Down

0 comments on commit d77efbd

Please sign in to comment.