Skip to content

Commit

Permalink
Don't return empty string as valid az for volumes
Browse files Browse the repository at this point in the history
Since OpenStack Liberty, Nova fails if create_vm
contains an element 'availablity_zone' in the body
with an empty string as value.

Fixes #54
[#135269529](https://www.pivotaltracker.com/story/show/135269529)

Signed-off-by: Tom Kiemes <tom.kiemes@sap.com>
  • Loading branch information
voelzmo authored and Kiemes committed Dec 2, 2016
1 parent aff8782 commit 958a827
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def select(volume_ids, resource_pool_az)
fog_volume_map = @openstack.volume.volumes
volumes = volume_ids.map { |vid| with_openstack { fog_volume_map.get(vid) } }
ensure_same_availability_zone(volumes, resource_pool_az)
volumes.first.availability_zone
ignore_empty_string(volumes.first.availability_zone)
else
resource_pool_az
end
Expand All @@ -24,6 +24,12 @@ def constrain_to_server_availability_zone?

private

def ignore_empty_string(string)
if string
string unless string.empty?
end
end

##
# Ensure all supplied availability zones are the same
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
let(:ignore_server_az) { false }

describe 'when the volume IDs are present' do
describe 'when az of volume is empty string' do
before do
allow(bar_volume).to receive(:availability_zone).and_return('')
end

it 'returns nil' do
expect(az_provider.select(['bar_id'], nil)).to be_nil
end
end

describe 'when az of volume is nil' do
before do
allow(bar_volume).to receive(:availability_zone).and_return(nil)
end

it 'returns nil' do
expect(az_provider.select(['bar_id'], nil)).to be_nil
end
end

describe 'when the volumes and resource pool are all from the same availability zone' do
before do
expect(bar_volume).to receive(:availability_zone).and_return('west_az')
Expand Down

0 comments on commit 958a827

Please sign in to comment.