(QENG-7530) Add check for unique hostnames

Prior to this commit the pooler had no awareness of the complete set of
hostnames that are currently in use. This meant that it was possible to
allocate the same hostname twice, which would result in the original
host with that hostname becoming unreachable.

This commit adds a check for the existence of the
`vmpooler__vm__<hostname>` key before attempting to  clone the vm.
This should prevent duplicate hostnames.

If the hostname is already taken, `_clone_vm` will retry with a new
random hostname multiple times before raising an exception.
This commit is contained in:
Brandon High 2019-11-01 15:26:51 -07:00
parent 1df13e4974
commit 019ed021b0
No known key found for this signature in database
GPG key ID: 270079C784FCAFDE
2 changed files with 28 additions and 2 deletions

View file

@ -608,6 +608,7 @@ EOT
expect(metrics).to receive(:timing).with(/clone\./,/0/)
expect(provider).to receive(:create_vm).with(pool, String)
allow(logger).to receive(:log)
expect(subject).to receive(:find_unique_hostname).with(pool).and_return(vm)
end
it 'should create a cloning VM' do
@ -649,6 +650,7 @@ EOT
before(:each) do
expect(provider).to receive(:create_vm).with(pool, String).and_raise('MockError')
allow(logger).to receive(:log)
expect(subject).to receive(:find_unique_hostname).with(pool).and_return(vm)
end
it 'should not create a cloning VM' do