From 90edc6f9792ebf1aad040d9a07eabcff1afded6d Mon Sep 17 00:00:00 2001 From: "kirby@puppetlabs.com" Date: Mon, 23 Jul 2018 16:50:03 -0700 Subject: [PATCH] Remove VM from completed only after destroy This commit updates destroy_vm to remove the redis member from the completed queue only after a destroy has been completed. Without this change a VM that is being destroyed will be logged as discovered when inventory is checked since it has already been removed from the completed queue. --- CHANGELOG.md | 1 + lib/vmpooler/pool_manager.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e7acc55..2a063fbe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ git logs & PR history. ### Fixed - (POOLER-128) VM specific mutex objects are not dereferenced when a VM is destroyed +- A VM that is being destroyed is reported as discovered # [0.1.0](/~https://github.com/puppetlabs/vmpooler/compare/4c858d012a262093383e57ea6db790521886d8d4...master) diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 666fb6653..1e489cbe8 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -298,7 +298,6 @@ def _destroy_vm(vm, pool, provider) mutex = vm_mutex(vm) return if mutex.locked? mutex.synchronize do - $redis.srem('vmpooler__completed__' + pool, vm) $redis.hdel('vmpooler__active__' + pool, vm) $redis.hset('vmpooler__vm__' + vm, 'destroy', Time.now) @@ -309,6 +308,8 @@ def _destroy_vm(vm, pool, provider) provider.destroy_vm(pool, vm) + $redis.srem('vmpooler__completed__' + pool, vm) + finish = format('%.2f', Time.now - start) $logger.log('s', "[-] [#{pool}] '#{vm}' destroyed in #{finish} seconds") $metrics.timing("destroy.#{pool}", finish)