Skip to content

Commit c8d7dd0

Browse files
authored
feat(interactive): Expose a http api for readiness probe (#4574)
Interactive lacks a probing method to denote whether the service could successfully process queries; we introduce `/v1/service/ready`. Also, we modify the `interactive-entrypoint.sh` to support initializing a workspace from an empty folder.
1 parent ae1470f commit c8d7dd0

File tree

6 files changed

+45
-13
lines changed

6 files changed

+45
-13
lines changed

docs/flex/interactive/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ In this following table, we use the `.` notation to represent the hierarchy with
114114
| -------- | -------- | -------- |----------- |
115115
| log_level | INFO | The level of database log, INFO/WARNING/ERROR/FATAL | 0.0.1 |
116116
| verbose_level | 0 | The verbose level of database log, should be a int | 0.0.3 |
117-
| compute_engine.thread_num_per_worker | 1 | The number of threads will be used to process the queries. Increase the number can benefit the query throughput | 0.0.1 |
117+
| compute_engine.thread_num_per_worker | 4 | The number of threads will be used to process the queries. Increase the number can benefit the query throughput | 0.0.1 |
118118
| compute_engine.wal_uri | file://{GRAPH_DATA_DIR}/wal | The location where Interactive will store and access WALs. `GRAPH_DATA_DIR` is a placeholder that will be populated by Interactive. | 0.5 |
119119
| compiler.planner.is_on | true | Determines if query optimization is enabled for compiling Cypher queries | 0.0.1 |
120120
| compiler.planner.opt | RBO | Specifies the optimizer to be used for query optimization. Currently, only the Rule-Based Optimizer (RBO) is supported | 0.0.1 |

flex/engines/http_server/actor/admin_actor.act.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,17 @@ seastar::future<admin_query_result> admin_actor::stop_service(
11251125
});
11261126
}
11271127

1128+
seastar::future<admin_query_result> admin_actor::service_ready(
1129+
query_param&& query_param) {
1130+
auto& graph_db_service = GraphDBService::get();
1131+
return graph_db_service.is_actors_running()
1132+
? seastar::make_ready_future<admin_query_result>(
1133+
gs::Result<seastar::sstring>("true"))
1134+
: seastar::make_exception_future<admin_query_result>(
1135+
gs::Status(gs::StatusCode::SERVICE_UNAVAILABLE,
1136+
"Service is not ready"));
1137+
}
1138+
11281139
// get service status
11291140
seastar::future<admin_query_result> admin_actor::service_status(
11301141
query_param&& query_param) {

flex/engines/http_server/actor/admin_actor.act.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class ANNOTATION(actor:impl) admin_actor : public hiactor::actor {
5252

5353
seastar::future<admin_query_result> ANNOTATION(actor:method) service_status(query_param&& param);
5454

55+
seastar::future<admin_query_result> ANNOTATION(actor:method) service_ready(query_param&& param);
56+
5557
seastar::future<admin_query_result> ANNOTATION(actor:method) get_procedure_by_procedure_name(procedure_query_param&& param);
5658

5759
seastar::future<admin_query_result> ANNOTATION(actor:method) get_procedures_by_graph_name(query_param&& param);

flex/engines/http_server/handler/admin_http_handler.cc

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,26 @@ class admin_http_service_handler_impl : public seastar::httpd::handler_base {
509509
std::move(rep), std::string("Unsupported action: ") + action);
510510
}
511511
} else {
512-
return admin_actor_refs_[dst_executor]
513-
.service_status(query_param{std::move(req->content)})
514-
.then_wrapped([rep = std::move(rep)](
515-
seastar::future<admin_query_result>&& fut) mutable {
516-
return return_reply_with_result(std::move(rep), std::move(fut));
517-
});
512+
// v1/service/ready or v1/service/status
513+
if (path.find("ready") != seastar::sstring::npos) {
514+
return admin_actor_refs_[dst_executor]
515+
.service_ready(query_param{std::move(req->content)})
516+
.then_wrapped(
517+
[rep = std::move(rep)](
518+
seastar::future<admin_query_result>&& fut) mutable {
519+
return return_reply_with_result(std::move(rep),
520+
std::move(fut));
521+
});
522+
} else {
523+
return admin_actor_refs_[dst_executor]
524+
.service_status(query_param{std::move(req->content)})
525+
.then_wrapped(
526+
[rep = std::move(rep)](
527+
seastar::future<admin_query_result>&& fut) mutable {
528+
return return_reply_with_result(std::move(rep),
529+
std::move(fut));
530+
});
531+
}
518532
}
519533
}
520534

@@ -831,6 +845,12 @@ seastar::future<> admin_http_handler::set_routes() {
831845
new admin_http_service_handler_impl(interactive_admin_group_id,
832846
shard_admin_concurrency,
833847
exclusive_shard_id_));
848+
849+
r.add(seastar::httpd::operation_type::GET,
850+
seastar::httpd::url("/v1/service/ready"),
851+
new admin_http_service_handler_impl(interactive_admin_group_id,
852+
shard_admin_concurrency,
853+
exclusive_shard_id_));
834854
}
835855

836856
{

flex/tests/hqps/interactive_config_test_cbo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ compute_engine:
44
type: hiactor
55
workers:
66
- localhost:10000
7-
thread_num_per_worker: 1
7+
thread_num_per_worker: 4
88
store:
99
type: cpp-mcsr
1010
compiler:

k8s/dockerfiles/interactive-entrypoint.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,16 @@ function prepare_workspace() {
5050
mkdir -p ${workspace}
5151
mkdir -p ${workspace}/conf/
5252
else
53-
echo "Workspace ${workspace} already exists"
54-
return 0
53+
if [ -f "${workspace}/conf/interactive_config.yaml" ]; then
54+
echo "Workspace ${workspace} already exists"
55+
return 0
56+
fi
5557
fi
5658
# prepare interactive_config.yaml
5759
engine_config_path="${workspace}/conf/interactive_config.yaml"
5860
cp ${DEFAULT_INTERACTIVE_CONFIG_FILE} $engine_config_path
5961
#make sure the line which start with default_graph is changed to default_graph: ${DEFAULT_GRAPH_NAME}
6062
sed -i "s/default_graph:.*/default_graph: ${DEFAULT_GRAPH_NAME}/" $engine_config_path
61-
# By default, we occupy the all available cpus
62-
cpus=$(grep -c ^processor /proc/cpuinfo)
63-
sed -i "s/thread_num_per_worker:.*/thread_num_per_worker: ${cpus}/" $engine_config_path
6463
echo "Using default graph: ${DEFAULT_GRAPH_NAME} to start the service"
6564

6665
# copy the builtin graph

0 commit comments

Comments
 (0)