mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
New configuration parameter 'vm_lifetime'
This allows for configurable TTLs for hosts in the 'running' queue.
This commit is contained in:
parent
080e4d9828
commit
cc90d6618e
1 changed files with 7 additions and 3 deletions
|
|
@ -30,6 +30,7 @@ end
|
|||
|
||||
# Set some defaults
|
||||
$config[:config]['task_limit'] ||= 10
|
||||
$config[:config]['vm_lifetime'] ||= 24
|
||||
|
||||
# Connect to Redis
|
||||
$redis = Redis.new
|
||||
|
|
@ -350,10 +351,13 @@ def check_pool pool
|
|||
$redis.smembers('vmware_host_pool__running__'+pool['name']).each do |vm|
|
||||
if ($redis.hget('vmware_host_pool__active__'+pool['name'], vm))
|
||||
running = (Time.now - Time.parse($redis.hget('vmware_host_pool__active__'+pool['name'], vm)))/60/60
|
||||
if (running > 12)
|
||||
if (
|
||||
($config[:config]['vm_lifetime'] > 0) and
|
||||
(running > $config[:config]['vm_lifetime'])
|
||||
)
|
||||
$redis.smove('vmware_host_pool__running__'+pool['name'], 'vmware_host_pool__completed__'+pool['name'], vm)
|
||||
|
||||
$logger.log('d', "[!] [#{pool['name']}] '#{vm}' reached end of TTL after 12 hours")
|
||||
$logger.log('d', "[!] [#{pool['name']}] '#{vm}' reached end of TTL after #{$config[:config]['vm_lifetime']} hours")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue