(POOLER-148) Fix undefined variable bug in _check_ready_vm.

The host['boottime'] variable in the function _check_ready_vm no longer
has its parent object in reference due to the refactoring in pull
request #269.  So in order to get the same information without the
performance impact from duplicate object lookups, we get similar
information from the time that the VM is ready.
This commit is contained in:
Andrew Makousky 2019-08-30 17:58:24 -05:00
parent df90d56721
commit 79ac9ad37e

View file

@ -156,8 +156,14 @@ module Vmpooler
$redis.hset('vmpooler__vm__' + vm, 'check', Time.now) $redis.hset('vmpooler__vm__' + vm, 'check', Time.now)
# Check if the hosts TTL has expired # Check if the hosts TTL has expired
if ttl > 0 if ttl > 0
# host['boottime'] may be nil if host is not powered on # 'boottime' may be nil if host is not powered on
if ((Time.now - host['boottime']) / 60).to_s[/^\d+\.\d{1}/].to_f > ttl 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) $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") $logger.log('d', "[!] [#{pool_name}] '#{vm}' reached end of TTL after #{ttl} minutes, removed from 'ready' queue")