add limit for borrowing machine: runtime <= 10 days
only jobs than runtime value is less than or equal to 10 days are allowed for borrowing machine.
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 964c520..54affa1 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -143,6 +143,7 @@ class Job
check_required_keys() check_account_info() + check_run_time() set_defaults() end
@@ -401,6 +402,15 @@ class Job @hash.delete("my_token") end
+ private def check_run_time + return unless @hash.has_key?("ssh_pub_key") + + 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)