add limit for borrowing machine: runtime <= 10 days
the job will break up if the value of runtime in the job yaml is greater than 10 days
Signed-off-by: Luan Shengde shdluan@163.com --- src/lib/job.cr | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 9b52d88..bb9b792 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -64,6 +64,7 @@ class Job return unless @hash.has_key?("my_uuid") || @hash.has_key?("my_token")
check_account_info() + check_run_time() set_sshr_info() return end @@ -410,6 +411,15 @@ class Job @hash.delete("my_token") end
+ private def check_run_time + return unless @hash["testcase"] == "borrow" + + max_run_time = 10 * 24 * 3600 + + error_msg = "The maximum runtime should no more than 10 days." + raise error_msg if hash["runtime"].to_i > max_run_time + end + private def is_valid_account?(account_info) return false unless account_info.is_a?(JSON::Any)