Skip to content

Commit

Permalink
Remove VM from completed only after destroy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mattkirby committed Jul 23, 2018
1 parent 10bf6c8 commit dddb81f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ git logs & PR history.

# [Unreleased](/~https://github.com/puppetlabs/vmpooler/compare/0.1.0...master)

### Fixed

- A VM that is being destroyed is reported as discovered

# [0.1.0](/~https://github.com/puppetlabs/vmpooler/compare/4c858d012a262093383e57ea6db790521886d8d4...master)

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion lib/vmpooler/pool_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit dddb81f

Please sign in to comment.