【发布时间】:2019-05-27 20:36:47
【问题描述】:
我在/status 有一个运行状况检查端点,它返回以下状态代码和响应正文:
- 健康 -
200 OK - 降级 -
? - 不健康 -
503 Service Unnavailable
对于降级响应的 HTTP 状态代码应该是什么? “降级”检查用于did succeed but are slow or unstable 的检查。什么 HTTP 状态代码最有意义?
【问题讨论】:
-
我认为你的问题没有意义。您需要决定 HTTP
GET或/status应该做什么 -
您认为您的选择是什么?如果它正常工作,我们使用 200 并在必要时返回附加信息。真的,这取决于你。
-
@MuhammadRehanSaeed 返回一个自定义代码,其 2xx 成功范围尚未采用已知/常用代码。类似于一些不受任何标准支持的unofficial codes。例如
218 This is fine (Apache Web Server) -
@MuhammadRehanSaeed 还发现了这个tools.ietf.org/html/draft-inadarei-api-health-check-00
-
@MuhammadRehanSaeed 希望您检查更多recent version 他们还建议
In case of the “warn” status, endpoints MUST return HTTP status in the 2xx-3xx range, and additional information SHOULD be provided, utilizing optional fields of the response.其中warn状态为healthy, with some concerns,我相信这与您的模式密切相关。
标签: http http-status-codes http-status-code-503 health-monitoring kubernetes-health-check