Skip to content

Commit

Permalink
Merge pull request #338 from quorten/master
Browse files Browse the repository at this point in the history
(POOLER-148) Fix undefined variable bug in _check_ready_vm.
  • Loading branch information
Samuel authored Sep 4, 2019
2 parents df90d56 + a2548d1 commit 79bd140
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/vmpooler/pool_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,14 @@ def _check_ready_vm(vm, pool_name, ttl, provider)
$redis.hset('vmpooler__vm__' + vm, 'check', Time.now)
# Check if the hosts TTL has expired
if ttl > 0
# host['boottime'] may be nil if host is not powered on
if ((Time.now - host['boottime']) / 60).to_s[/^\d+\.\d{1}/].to_f > ttl
# if 'boottime' is nil, set bootime to beginning of unix epoch, forces TTL to be assumed expired
boottime = $redis.hget("vmpooler__vm__#{vm}", 'ready')
if boottime
boottime = Time.parse(boottime)
else
boottime = Time.at(0)
end
if ((Time.now - boottime) / 60).to_s[/^\d+\.\d{1}/].to_f > ttl
$redis.smove('vmpooler__ready__' + pool_name, 'vmpooler__completed__' + pool_name, vm)

$logger.log('d', "[!] [#{pool_name}] '#{vm}' reached end of TTL after #{ttl} minutes, removed from 'ready' queue")
Expand Down

0 comments on commit 79bd140

Please sign in to comment.