[why]
Every request to scheduler will initialize a new 'Sched', each 'Sched' will
new a 'BlockHelper'. For each node in cluster, it can't release when blocking
at scheduler because they use different locks.
[how]
Set an instance of 'BlockHelper' to class variable.
Signed-off-by: Ren Wen <15991987063(a)163.com>
---
src/lib/sched.cr | 3 ++-
src/scheduler/request_cluster_state.cr | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr
index f7220f9..25e3708 100644
--- a/src/lib/sched.cr
+++ b/src/lib/sched.cr
@@ -28,11 +28,12 @@ class Sched
property redis
property block_helper
+ @@block_helper = BlockHelper.new
+
def initialize(env : HTTP::Server::Context)
@es = Elasticsearch::Client.new
@redis = Redis::Client.new
@task_queue = TaskQueueAPI.new
- @block_helper = BlockHelper.new
@rgc = RemoteGitClient.new
@env = env
@log = env.log.as(JSONLogger)
diff --git a/src/scheduler/request_cluster_state.cr b/src/scheduler/request_cluster_state.cr
index 1782797..0703792 100644
--- a/src/scheduler/request_cluster_state.cr
+++ b/src/scheduler/request_cluster_state.cr
@@ -25,7 +25,7 @@ class Sched
update_cluster_state(cluster_id, job_id, {"state" => states[request_state]})
when "wait_ready"
update_cluster_state(cluster_id, job_id, {"state" => states[request_state]})
- @block_helper.block_until_finished(cluster_id) {
+ @@block_helper.block_until_finished(cluster_id) {
cluster_state = sync_cluster_state(cluster_id, job_id, states[request_state])
cluster_state == "ready" || cluster_state == "abort"
}
--
2.23.0