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" + + raise error_msg if @hash["pp"]["sleep"]["runtime"].as_i > max_run_time + end + private def is_valid_account?(account_info) return false unless account_info.is_a?(JSON::Any)
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
- # 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.
it is suggested to use the message in the last version.
- raise error_msg if @hash["pp"]["sleep"]["runtime"].as_i > max_run_time
Why not use runtime in top-level?
it is suggested to use the key in 'pp', for it gets the value in 'pp' in the final.
Thanks, Luan Shengde
Thanks, Xueliang
- end
- private def is_valid_account?(account_info) return false unless account_info.is_a?(JSON::Any)
-- 2.23.0
On Thu, Feb 25, 2021 at 11:59:34AM +0800, Wu Fengguang wrote:
- raise error_msg if @hash["pp"]["sleep"]["runtime"].as_i > max_run_time
sleep is special.
exec sleep ${1:-$runtime}
It may also directly take a cmdline parameter. Like this in some job:
sleep: 10d
We shall also check that form.
OK, I got it.
Thanks, Luan Shengde
Thanks, Fengguang