Ensure vm is removed from migrations

This commit is contained in:
kirby@puppetlabs.com 2017-11-12 11:41:29 -08:00 committed by mattkirby
parent 048ab4433a
commit 021633cd49
3 changed files with 4 additions and 13 deletions

View file

@ -925,6 +925,7 @@ module Vmpooler
finish = migrate_vm_and_record_timing(pool_name, vm_name, vm_hash, target_host_object, target_host_name) finish = migrate_vm_and_record_timing(pool_name, vm_name, vm_hash, target_host_object, target_host_name)
#logger.log('s', "Provider_hosts is: #{provider.provider_hosts}") #logger.log('s', "Provider_hosts is: #{provider.provider_hosts}")
logger.log('s', "[>] [#{pool_name}] '#{vm_name}' migrated from #{vm_hash['host_name']} to #{target_host_name} in #{finish} seconds") logger.log('s', "[>] [#{pool_name}] '#{vm_name}' migrated from #{vm_hash['host_name']} to #{target_host_name} in #{finish} seconds")
ensure
$redis.srem('vmpooler__migration', vm_name) $redis.srem('vmpooler__migration', vm_name)
end end

View file

@ -619,9 +619,7 @@ EOT
expect(redis.get('vmpooler__tasks__clone')).to eq('1') expect(redis.get('vmpooler__tasks__clone')).to eq('1')
end end
it 'should log messages that the clone failed' do it 'should raise the error' do
expect(logger).to receive(:log).with('s', /\[!\] \[#{pool}\] '(.+)' clone failed with an error: MockError/)
expect{subject._clone_vm(pool_object,provider)}.to raise_error(/MockError/) expect{subject._clone_vm(pool_object,provider)}.to raise_error(/MockError/)
end end
end end
@ -1493,13 +1491,6 @@ EOT
it 'logs a message' do it 'logs a message' do
allow(logger).to receive(:log) allow(logger).to receive(:log)
expect(logger).to receive(:log).with('s', "[x] [#{pool}] '#{vm}' migration failed with an error: MockError") expect(logger).to receive(:log).with('s', "[x] [#{pool}] '#{vm}' migration failed with an error: MockError")
expect(provider).to receive(:remove_vmpooler_migration_vm).with(pool, vm)
subject.migrate_vm(vm, pool, provider)
end
it 'should attempt to remove from vmpooler_migration queue' do
expect(provider).to receive(:remove_vmpooler_migration_vm).with(pool, vm, redis)
subject.migrate_vm(vm, pool, provider) subject.migrate_vm(vm, pool, provider)
end end
@ -2783,7 +2774,6 @@ EOT
expect(subject).to receive(:clone_vm).and_raise(RuntimeError,"MockError") expect(subject).to receive(:clone_vm).and_raise(RuntimeError,"MockError")
expect(logger).to receive(:log).with("s", "[!] [#{pool}] clone failed during check_pool with an error: MockError") expect(logger).to receive(:log).with("s", "[!] [#{pool}] clone failed during check_pool with an error: MockError")
expect(logger).to receive(:log).with('d', "[!] [#{pool}] _check_pool failed with an error: MockError")
expect{ subject._check_pool(pool_object,provider) }.to raise_error(RuntimeError,'MockError') expect{ subject._check_pool(pool_object,provider) }.to raise_error(RuntimeError,'MockError')
end end

View file

@ -1639,7 +1639,7 @@ EOT
let(:model) { 'v4' } let(:model) { 'v4' }
let(:different_model) { 'different_model' } let(:different_model) { 'different_model' }
let(:limit) { 75 } let(:limit) { 75 }
let(:default_limit) { 80 } let(:default_limit) { 90 }
context "host with a different model" do context "host with a different model" do
let(:host) { mock_RbVmomi_VIM_HostSystem() } let(:host) { mock_RbVmomi_VIM_HostSystem() }
@ -3029,7 +3029,7 @@ EOT
allow(relocate_task).to receive(:wait_for_completion) allow(relocate_task).to receive(:wait_for_completion)
end end
it 'should call RelovateVM_Task' do it 'should call RelocateVM_Task' do
expect(vm_object).to receive(:RelocateVM_Task).and_return(relocate_task) expect(vm_object).to receive(:RelocateVM_Task).and_return(relocate_task)
subject.migrate_vm_host(vm_object,host_object) subject.migrate_vm_host(vm_object,host_object)