Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v22.1.x] Schema Registry and REST Proxy: health checks #8000

Closed
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions src/v/pandaproxy/api/api-doc/rest.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,4 +547,18 @@
}
}
}
},
"/status/ready": {
"get": {
"summary": "Health check",
"operationId": "http_rest_status_ready",
"responses": {
"200": {
"description": "Success"
},
"503": {
"description": "Service Unavailable"
}
}
}
}
14 changes: 14 additions & 0 deletions src/v/pandaproxy/api/api-doc/schema_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,18 @@
}
}
}
},
"/status/ready": {
"get": {
"summary": "Health check",
"operationId": "schema_registry_status_ready",
"responses": {
"200": {
"description": "Success"
},
"503": {
"description": "Service Unavailable"
}
}
}
}
11 changes: 11 additions & 0 deletions src/v/pandaproxy/rest/handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,15 @@ post_consumer_offsets(server::request_t rq, server::reply_t rp) {
group_shard, rq.context().smp_sg, std::move(handler));
}

ss::future<proxy::server::reply_t>
status_ready(proxy::server::request_t rq, proxy::server::reply_t rp) {
auto make_metadata_req = []() {
return kafka::metadata_request{.list_all_topics = false};
};

auto res = co_await rq.dispatch(make_metadata_req);
rp.rep->set_status(ss::httpd::reply::status_type::ok);
co_return rp;
}

} // namespace pandaproxy::rest
3 changes: 3 additions & 0 deletions src/v/pandaproxy/rest/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ ss::future<ctx_server<proxy>::reply_t> get_consumer_offsets(
ss::future<ctx_server<proxy>::reply_t> post_consumer_offsets(
ctx_server<proxy>::request_t rq, ctx_server<proxy>::reply_t rp);

ss::future<proxy::server::reply_t>
status_ready(proxy::server::request_t rq, proxy::server::reply_t rp);

} // namespace pandaproxy::rest
4 changes: 4 additions & 0 deletions src/v/pandaproxy/rest/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ server::routes_t get_proxy_routes() {
routes.routes.emplace_back(server::route_t{
ss::httpd::rest_json::post_consumer_offsets, post_consumer_offsets});

routes.routes.emplace_back(server::route_t{
ss::httpd::rest_json::http_rest_status_ready,
wrap(gate, es, status_ready)});

return routes;
}

Expand Down
7 changes: 7 additions & 0 deletions src/v/pandaproxy/schema_registry/handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,11 @@ compatibility_subject_version(server::request_t rq, server::reply_t rp) {
co_return rp;
}

ss::future<server::reply_t>
status_ready(server::request_t rq, server::reply_t rp) {
co_await rq.service().writer().read_sync();
rp.rep->set_status(ss::httpd::reply::status_type::ok);
co_return rp;
}

} // namespace pandaproxy::schema_registry
3 changes: 3 additions & 0 deletions src/v/pandaproxy/schema_registry/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ ss::future<ctx_server<service>::reply_t> delete_subject_version(
ss::future<ctx_server<service>::reply_t> compatibility_subject_version(
ctx_server<service>::request_t rq, ctx_server<service>::reply_t rp);

ss::future<ctx_server<service>::reply_t> status_ready(
ctx_server<service>::request_t rq, ctx_server<service>::reply_t rp);

} // namespace pandaproxy::schema_registry
4 changes: 4 additions & 0 deletions src/v/pandaproxy/schema_registry/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ server::routes_t get_schema_registry_routes(ss::gate& gate, one_shot& es) {
ss::httpd::schema_registry_json::compatibility_subject_version,
wrap(gate, es, compatibility_subject_version)});

routes.routes.emplace_back(server::route_t{
ss::httpd::schema_registry_json::schema_registry_status_ready,
wrap(gate, es, status_ready)});

return routes;
}

Expand Down