Add liveness endpoint to admin server (#470)

Relates to https://github.com/linkerd/linkerd2/issues/3984

Add a `/live` endpoint to the admin server which always returns a 200 success.  This can be used for liveness checking.

Signed-off-by: Alex Leong <alex@buoyant.io>
This commit is contained in:
Alex Leong 2020-04-13 10:48:51 -07:00 committed by GitHub
parent 270d343bf5
commit feed830285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -59,6 +59,13 @@ impl<M: FmtMetrics> Admin<M> {
.expect("builder with known status code must not fail") .expect("builder with known status code must not fail")
} }
} }
fn live_rsp(&self) -> Response<Body> {
Response::builder()
.status(StatusCode::OK)
.body("live\n".into())
.expect("builder with known status code must not fail")
}
} }
impl<M: FmtMetrics> Service for Admin<M> { impl<M: FmtMetrics> Service for Admin<M> {
@ -72,6 +79,7 @@ impl<M: FmtMetrics> Service for Admin<M> {
"/metrics" => Box::new(self.metrics.call(req)), "/metrics" => Box::new(self.metrics.call(req)),
"/proxy-log-level" => self.trace_level.call(req), "/proxy-log-level" => self.trace_level.call(req),
"/ready" => Box::new(future::ok(self.ready_rsp())), "/ready" => Box::new(future::ok(self.ready_rsp())),
"/live" => Box::new(future::ok(self.live_rsp())),
_ => Box::new(future::ok(rsp(StatusCode::NOT_FOUND, Body::empty()))), _ => Box::new(future::ok(rsp(StatusCode::NOT_FOUND, Body::empty()))),
} }
} }