On Tue, Jan 26, 2021 at 05:59:03PM +0800, Luan Shengde wrote:
Add limit for borrowing machine: borrowing period <= 10 days
Only jobs that runtime/sleep value is less than or equal to 10 days are allowed to borrow machines.
The runtime and sleep tow fields are the same meaning for borrowing machine, that's not friendly for user.
Thanks, Xueliang
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 964c520..5448082 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,19 @@ class Job @hash.delete("my_token") end
- private def check_run_time
- return unless @hash.has_key?("ssh_pub_key")
- # runtime value is converted to second.
- max_run_time = 10 * 24 * 3600
- error_msg = "The maximum runtime should no more than 10 days."
- # case runtime value is more than 10 days, job will fail.
- raise error_msg if hash["runtime"].to_i > max_run_time
- raise error_msg if hash["sleep"].to_i > max_run_time
- end
- private def is_valid_account?(account_info) return false unless account_info.is_a?(JSON::Any)
-- 2.23.0