Skip to content

Commit

Permalink
Merge pull request #19908 from fdupont-redhat/v2v_bz_1809035
Browse files Browse the repository at this point in the history
[V2V] Allow job to continue if kill_virtv2v raises an execption

(cherry picked from commit cf44de0)

https://bugzilla.redhat.com/show_bug.cgi?id=1809035
  • Loading branch information
agrare authored and simaishi committed Apr 13, 2020
1 parent 8bc4cf6 commit fcfcd4b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/infra_conversion_job.rb
Expand Up @@ -628,7 +628,7 @@ def abort_virtv2v
end

migration_task.kill_virtv2v('TERM') if context["retries_#{state}".to_sym] == 1
queue_signal(:abort_virtv2v)
queue_signal(:abort_virtv2v, :deliver_on => Time.now.utc + state_retry_interval)
end

def poll_automate_state_machine
Expand Down
4 changes: 4 additions & 0 deletions app/models/service_template_transformation_plan_task.rb
Expand Up @@ -285,6 +285,10 @@ def kill_virtv2v(signal = 'TERM')

_log.info("Killing conversion pod for task '#{id}'.")
conversion_host.kill_virtv2v(id, signal)
rescue => err
_log.error("Couldn't kill conversion pod for task '#{id}': #{err.message}")
update_options(:virtv2v_finished_on => Time.now.utc.strftime('%Y-%m-%d %H:%M:%S'))
false
end

def virtv2v_running?
Expand Down
16 changes: 10 additions & 6 deletions spec/models/infra_conversion_job_spec.rb
Expand Up @@ -1636,15 +1636,19 @@
end

it 'sends TERM signal and retries to virt-v2v when entering state for the first time' do
expect(job.migration_task).to receive(:kill_virtv2v).with('TERM')
expect(job).to receive(:queue_signal).with(:abort_virtv2v)
job.abort_virtv2v
Timecop.freeze(2019, 2, 6) do
expect(job.migration_task).to receive(:kill_virtv2v).with('TERM')
expect(job).to receive(:queue_signal).with(:abort_virtv2v, :deliver_on => Time.now.utc + job.state_retry_interval)
job.abort_virtv2v
end
end

it 'retries if not entering the state for the first time' do
job.context[:retries_aborting_virtv2v] = 1
expect(job).to receive(:queue_signal).with(:abort_virtv2v)
job.abort_virtv2v
Timecop.freeze(2019, 2, 6) do
job.context[:retries_aborting_virtv2v] = 1
expect(job).to receive(:queue_signal).with(:abort_virtv2v, :deliver_on => Time.now.utc + job.state_retry_interval)
job.abort_virtv2v
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/models/service_template_transformation_plan_task_spec.rb
Expand Up @@ -240,6 +240,14 @@
allow(conversion_host).to receive(:kill_virtv2v).with(task.id, 'KILL').and_return(true)
expect(task.kill_virtv2v('KILL')).to eq(true)
end

it "considers virt-v2v finished or returns false if an exception occurs" do
Timecop.freeze(2019, 2, 6) do
allow(task).to receive(:get_conversion_state).and_raise('fake error')
expect(task.kill_virtv2v('TERM')).to eq(false)
expect(task.options[:virtv2v_finished_on]).to eq(Time.now.utc.strftime('%Y-%m-%d %H:%M:%S'))
end
end
end
end

Expand Down

0 comments on commit fcfcd4b

Please sign in to comment.