mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #292 from mattkirby/remove_mutex_on_destroy
(POOLER-128) Remove references to VM mutex when destroying
This commit is contained in:
commit
10efddd43e
3 changed files with 39 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ git logs & PR history.
|
||||||
|
|
||||||
# [Unreleased](https://github.com/puppetlabs/vmpooler/compare/0.1.0...master)
|
# [Unreleased](https://github.com/puppetlabs/vmpooler/compare/0.1.0...master)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (POOLER-128) VM specific mutex objects are not dereferenced when a VM is destroyed
|
||||||
|
|
||||||
# [0.1.0](https://github.com/puppetlabs/vmpooler/compare/4c858d012a262093383e57ea6db790521886d8d4...master)
|
# [0.1.0](https://github.com/puppetlabs/vmpooler/compare/4c858d012a262093383e57ea6db790521886d8d4...master)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,7 @@ module Vmpooler
|
||||||
$logger.log('s', "[-] [#{pool}] '#{vm}' destroyed in #{finish} seconds")
|
$logger.log('s', "[-] [#{pool}] '#{vm}' destroyed in #{finish} seconds")
|
||||||
$metrics.timing("destroy.#{pool}", finish)
|
$metrics.timing("destroy.#{pool}", finish)
|
||||||
end
|
end
|
||||||
|
dereference_mutex(vm)
|
||||||
end
|
end
|
||||||
|
|
||||||
def purge_unused_vms_and_folders
|
def purge_unused_vms_and_folders
|
||||||
|
|
@ -681,6 +682,14 @@ module Vmpooler
|
||||||
@vm_mutex[vmname] || @vm_mutex[vmname] = Mutex.new
|
@vm_mutex[vmname] || @vm_mutex[vmname] = Mutex.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dereference_mutex(vmname)
|
||||||
|
if @vm_mutex.delete(vmname)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def sync_pool_template(pool)
|
def sync_pool_template(pool)
|
||||||
pool_template = $redis.hget('vmpooler__config__template', pool['name'])
|
pool_template = $redis.hget('vmpooler__config__template', pool['name'])
|
||||||
if pool_template
|
if pool_template
|
||||||
|
|
|
||||||
|
|
@ -726,6 +726,12 @@ EOT
|
||||||
|
|
||||||
subject._destroy_vm(vm,pool,provider)
|
subject._destroy_vm(vm,pool,provider)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should dereference the mutex' do
|
||||||
|
expect(subject).to receive(:dereference_mutex)
|
||||||
|
|
||||||
|
subject._destroy_vm(vm,pool,provider)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the VM destruction raises an eror' do
|
context 'when the VM destruction raises an eror' do
|
||||||
|
|
@ -1690,6 +1696,26 @@ EOT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#dereference_mutex' do
|
||||||
|
it 'should return nil when no mutex is dereferenced' do
|
||||||
|
expect(subject.dereference_mutex(vm)).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return true when a mutex is dereferenced' do
|
||||||
|
subject.vm_mutex(vm)
|
||||||
|
expect(subject.dereference_mutex(vm)).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should dereference the mutex' do
|
||||||
|
mutex = subject.vm_mutex(vm)
|
||||||
|
|
||||||
|
subject.dereference_mutex(vm)
|
||||||
|
|
||||||
|
result = subject.vm_mutex(vm)
|
||||||
|
expect(result).to_not eq(mutex)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'sync_pool_template' do
|
describe 'sync_pool_template' do
|
||||||
let(:old_template) { 'templates/old-template' }
|
let(:old_template) { 'templates/old-template' }
|
||||||
let(:new_template) { 'templates/new-template' }
|
let(:new_template) { 'templates/new-template' }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue