mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
Merge pull request #619 from puppetlabs/handle_clone_no_ip
(maint) Raise error when ip address is not given to vm after clone.
This commit is contained in:
commit
b5a3d7dc0a
2 changed files with 16 additions and 2 deletions
|
|
@ -470,6 +470,9 @@ module Vmpooler
|
|||
ip_start = Time.now
|
||||
ip = provider.get_vm_ip_address(new_vmname, pool_name)
|
||||
ip_finish = format('%<time>.2f', time: Time.now - ip_start)
|
||||
|
||||
raise StandardError, "failed to obtain IP after #{ip_finish} seconds" if ip.nil?
|
||||
|
||||
$logger.log('s', "[+] [#{pool_name}] Obtained IP for '#{new_vmname}' in #{ip_finish} seconds")
|
||||
|
||||
@redis.with_metrics do |redis|
|
||||
|
|
|
|||
|
|
@ -989,7 +989,7 @@ EOT
|
|||
allow(metrics).to receive(:timing)
|
||||
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
||||
expect(provider).to receive(:create_vm).with(pool, String)
|
||||
allow(provider).to receive(:get_vm_ip_address)
|
||||
allow(provider).to receive(:get_vm_ip_address).and_return(1)
|
||||
allow(subject).to receive(:get_domain_for_pool).and_return('example.com')
|
||||
allow(subject).to receive(:get_dns_plugin_class_name_for_pool).and_return(dns_plugin)
|
||||
allow(logger).to receive(:log)
|
||||
|
|
@ -1035,6 +1035,17 @@ EOT
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a failure to get ip address after cloning' do
|
||||
it 'should log a message that it completed being cloned' do
|
||||
allow(metrics).to receive(:timing)
|
||||
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
||||
expect(provider).to receive(:create_vm).with(pool, String)
|
||||
allow(provider).to receive(:get_vm_ip_address).and_return(nil)
|
||||
|
||||
expect{subject._clone_vm(pool,provider,dns_plugin)}.to raise_error(StandardError)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an error during cloning' do
|
||||
before(:each) do
|
||||
expect(provider).to receive(:create_vm).with(pool, String).and_raise('MockError')
|
||||
|
|
@ -1088,7 +1099,7 @@ EOT
|
|||
allow(metrics).to receive(:timing)
|
||||
expect(metrics).to receive(:timing).with(/clone\./,/0/)
|
||||
expect(provider).to receive(:create_vm).with(pool, String)
|
||||
allow(provider).to receive(:get_vm_ip_address).with(vm,pool)
|
||||
allow(provider).to receive(:get_vm_ip_address).with(vm,pool).and_return(1)
|
||||
allow(subject).to receive(:get_dns_plugin_class_name_for_pool).and_return(dns_plugin)
|
||||
expect(dns_plugin).to receive(:create_or_replace_record)
|
||||
allow(logger).to receive(:log)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue