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

[V2V] Allow a retry to let virt-v2v start #479

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 @@ -44,8 +44,12 @@ def main
@handle.set_state_var(:ae_state_progress, 'message' => 'Disks transformation succeeded.', 'percent' => 100)
end
rescue => e
@handle.set_state_var(:ae_state_progress, 'message' => e.message)
raise
if @handle.root['ae_state_retries'] > 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdupont-redhat Are their specific exceptions that we should catch or is it that the first exception is always caught and ignored and along the way we suppress the exception which will never get raised.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkanoor The exception will be raised again if it's legit, meaning that it actually failed. If it was only because virt-v2v-wrapper has not created the state file, a retry should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@handle.set_state_var(:ae_state_progress, 'message' => e.message)
raise
else
set_retry
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
allow(svc_model_task).to receive(:get_option).with(:virtv2v_status).and_return('active')
described_class.new(ae_service).main
expect(ae_service.get_state_var(:ae_state_progress)).to eq('message' => 'Disks transformation is initializing.', 'percent' => 1.0)
expect(ae_service.root['ae_result']).to eq('retry')
end
end

Expand All @@ -63,11 +64,13 @@
allow(svc_model_task).to receive(:get_option).with(:virtv2v_status).and_return('active')
described_class.new(ae_service).main
expect(ae_service.get_state_var(:ae_state_progress)).to eq('message' => 'Converting disk 2 / 2 [43.75%].', 'percent' => 43.75)
expect(ae_service.root['ae_result']).to eq('retry')
end
end

context "conversion has failed" do
it "raises with a message stating conversion has failed" do
ae_service.root['ae_state_retries'] = 2
allow(svc_model_task).to receive(:get_conversion_state).and_return(true)
allow(svc_model_task).to receive(:get_option).with(:virtv2v_status).and_return('failed')
errormsg = 'Disks transformation failed.'
Expand All @@ -85,11 +88,22 @@
end
end

it "raises if get_conversion_state fails" do
errormsg = 'Unexpected error'
allow(svc_model_task).to receive(:get_conversion_state).and_raise(errormsg)
expect { described_class.new(ae_service).main }.to raise_error(errormsg)
expect(ae_service.get_state_var(:ae_state_progress)).to eq('message' => errormsg)
context "get_conversion_state fails" do
it "sets retry if ae_state_retries is less than or equal to 1" do
errormsg = 'Unexpected error'
allow(svc_model_task).to receive(:get_conversion_state).and_raise(errormsg)
ae_service.root['ae_state_retries'] = 1
described_class.new(ae_service).main
expect(ae_service.root['ae_result']).to eq('retry')
end

it "raises if ae_state_retries is greater than 2" do
errormsg = 'Unexpected error'
allow(svc_model_task).to receive(:get_conversion_state).and_raise(errormsg)
ae_service.root['ae_state_retries'] = 2
expect { described_class.new(ae_service).main }.to raise_error(errormsg)
expect(ae_service.get_state_var(:ae_state_progress)).to eq('message' => errormsg)
end
end
end
end