From e0fac0bb6c9ee7771f506b1a98cd9a9d0eba793f Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Fri, 9 Oct 2020 10:23:23 -0500 Subject: [PATCH 1/2] (maint) Add more uniqueness to jobid Before this change there was a non zero chance that two requests could be received at the same millisecond and have the same jobid. Added the username as a prefix to the job id --- lib/vmfloaty/abs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vmfloaty/abs.rb b/lib/vmfloaty/abs.rb index 2426c32..1d1755a 100644 --- a/lib/vmfloaty/abs.rb +++ b/lib/vmfloaty/abs.rb @@ -248,7 +248,7 @@ class ABS conn = Http.get_conn(verbose, url) conn.headers['X-AUTH-TOKEN'] = token if token - saved_job_id = DateTime.now.strftime('%Q') + saved_job_id = user + "-" + DateTime.now.strftime('%Q') vmpooler_config = Utils.get_vmpooler_service_config(config['vmpooler_fallback']) req_obj = { :resources => os_types, From 671623bc4f13d77ff91c2b755560520cdd6c5f0f Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Fri, 9 Oct 2020 10:37:16 -0500 Subject: [PATCH 2/2] handle ctrl-c and term signal and return useful message on how to query ABS for the state of the request or to delete it --- lib/vmfloaty/abs.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/vmfloaty/abs.rb b/lib/vmfloaty/abs.rb index 1d1755a..4eb657e 100644 --- a/lib/vmfloaty/abs.rb +++ b/lib/vmfloaty/abs.rb @@ -284,15 +284,20 @@ class ABS validate_queue_status_response(res.status, res.body, "Initial request", verbose) - (1..retries).each do |i| - queue_place, res_body = check_queue(conn, saved_job_id, req_obj, verbose) - return translated(res_body, saved_job_id) if res_body + begin + (1..retries).each do |i| + queue_place, res_body = check_queue(conn, saved_job_id, req_obj, verbose) + return translated(res_body, saved_job_id) if res_body - sleep_seconds = 10 if i >= 10 - sleep_seconds = i if i < 10 - FloatyLogger.info "Waiting #{sleep_seconds} seconds to check if ABS request has been filled. Queue Position: #{queue_place}... (x#{i})" + sleep_seconds = 10 if i >= 10 + sleep_seconds = i if i < 10 + FloatyLogger.info "Waiting #{sleep_seconds} seconds to check if ABS request has been filled. Queue Position: #{queue_place}... (x#{i})" - sleep(sleep_seconds) + sleep(sleep_seconds) + end + rescue SystemExit, Interrupt + FloatyLogger.info "\n\nFloaty interrupted, you can query the state of your request via\n1) `floaty query #{saved_job_id}` or delete it via\n2) `floaty delete #{saved_job_id}`" + exit 1 end nil end