mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-25 21:28:40 -05:00
Merge branch 'master' into maint/dont-require-fallback-config
This commit is contained in:
commit
ad8196970c
6 changed files with 63 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue