On Thu, Feb 25, 2021 at 09:36:16AM +0800, Luan Shengde wrote:
add limit for borrowing machine, the max runtime is limited to no more than 10 days.
case the runtime beyond the limit, it will throw error message and prevent the submit for borrowing machine.
Signed-off-by: Luan Shengde shdluan@163.com
src/lib/job.cr | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/lib/job.cr b/src/lib/job.cr index c3eeaf4..db1af2b 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -145,6 +145,7 @@ class Job
check_required_keys() check_account_info()
- check_run_time() set_defaults() end
@@ -405,6 +406,20 @@ class Job @hash.delete("my_token") end
- private def check_run_time
- # only job.yaml for borrowing machine has the key: ssh_pub_key
- return unless @hash.has_key?("ssh_pub_key")
- # the maxmum borrowing time is limited no more than 10 days.
- # case the runtime/sleep value count beyond the limit,
- # it will throw error message and prevent the submit for borrowing machine.
- # runtime value is converted to second.
- max_run_time = 10 * 24 * 3600
- error_msg = "\nMachine borrow time cannot exceed 10 days. Consider re-borrow.\n"
The runtime cannot exceed 10 days in machine borrow. Consider re-borrow.
- raise error_msg if @hash["pp"]["sleep"]["runtime"].as_i > max_run_time
Why not use runtime in top-level?
Thanks, Xueliang
- end
- private def is_valid_account?(account_info) return false unless account_info.is_a?(JSON::Any)
-- 2.23.0