Merge branch 'master' into maint/dont-require-fallback-config

This commit is contained in:
Samuel 2020-10-09 14:54:29 -05:00 committed by GitHub
commit ad8196970c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 28 deletions

View file

@ -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')
req_obj = {
:resources => os_types,
:job => {
@ -259,7 +259,7 @@ class ABS
},
}
if config['vmpooler_fallback']
if config['vmpooler_fallback'] # optional and not available as cli flag
vmpooler_config = Utils.get_vmpooler_service_config(config['vmpooler_fallback'])
# request with this token, on behalf of this user
req_obj[:vm_token] = vmpooler_config['token']
@ -288,15 +288,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

View file

@ -139,7 +139,7 @@ class Service
# some methods do not exist for ABS, and if possible should target the Pooler service
def maybe_use_vmpooler
if @service_object.is_a?(ABS.class)
if @service_object == ABS # this is not an instance
if !self.silent
FloatyLogger.info "The service in use is ABS, but the requested method should run against vmpooler directly, using fallback_vmpooler config from ~/.vmfloaty.yml"
self.silent = true

View file

@ -116,7 +116,7 @@ class Utils
output_target.puts "- [JobID:#{host_data['request']['job']['id']}] <#{host_data['state']}>"
host_data['allocated_resources'].each do |allocated_resources, _i|
if allocated_resources['engine'] == "vmpooler"
if allocated_resources['engine'] == "vmpooler" && service.config["vmpooler_fallback"]
vmpooler_service = service.clone
vmpooler_service.silent = true
vmpooler_service.maybe_use_vmpooler
@ -254,6 +254,7 @@ class Utils
'url' => config['url'],
'user' => config['user'],
'token' => config['token'],
'vmpooler_fallback' => config['vmpooler_fallback'],
'type' => config['type'] || 'vmpooler',
}