(POOLER-31) Expire redis vm key when clone fails

This commit updates pool_manager to expire a redis VM key when a clone fails. Without this change VMs that fail to clone have their metadata left forever.
This commit is contained in:
kirby@puppetlabs.com 2018-06-20 17:27:31 -07:00
parent de813943e9
commit 3a6e2a5cac
2 changed files with 11 additions and 1 deletions

View file

@ -245,7 +245,9 @@ module Vmpooler
$metrics.timing("clone.#{pool_name}", finish)
rescue => _err
$redis.srem('vmpooler__pending__' + pool_name, new_vmname)
$redis.srem("vmpooler__pending__#{pool_name}", new_vmname)
expiration_ttl = $config[:redis]['data_ttl'].to_i * 60 * 60
$redis.expire("vmpooler__vm__#{new_vmname}", expiration_ttl)
raise _err
ensure
$redis.decr('vmpooler__tasks__clone')