Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch error when volume creation fails #269

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def do_volume_creation_check(volumes_refs)
source.ext_management_system.with_provider_connection(connection_options) do |service|
volumes_refs.each do |volume_attrs|
next unless volume_attrs[:source_type] == "volume"
status = service.volumes.get(volume_attrs[:uuid]).try(:status)
volume = service.volumes.get(volume_attrs[:uuid])
status = volume.try(:status)
if status == "error"
raise MiqException::MiqProvisionError, "An error occurred while creating Volume #{volume.name}"
end
return false, status unless status == "available"
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,15 @@

expect(@task.do_volume_creation_check([pending_volume_attrs])).to eq [false, nil]
end

it "status error" do
pending_volume_attrs = {:source_type => "volume"}
service = double
allow(service).to receive_message_chain('volumes.get').and_return FactoryGirl.build(:cloud_volume_openstack,
:status => "error")
allow(@task.source.ext_management_system).to receive(:with_provider_connection)\
.with(:service => 'volume').and_yield(service)
expect { @task.do_volume_creation_check([pending_volume_attrs]) }.to raise_error(MiqException::MiqProvisionError)
end
end
end