
the maximum time for borrowing machine should no more than 10 days. Signed-off-by: Luan Shengde <shdluan@163.com> --- src/lib/job.cr | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/job.cr b/src/lib/job.cr index 9b52d88..e9e693c 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,19 @@ class Job @hash.delete("my_token") end + private def check_run_time + return unless @hash["testcase"] == "borrow" + + if @hash["runtime"].ends_with? "d" + hour = hash["runtime"][0..-2].to_i * 24 + elsif @hash["runtime"].ends_with? "h" + hour = hash["runtime"][0..-2].to_i + end + + error_msg = "The maximum runtime should no more than 10 days." + raise error_msg if hour.is_a?(Int32) && hour >= 240 + end + private def is_valid_account?(account_info) return false unless account_info.is_a?(JSON::Any) -- 2.23.0