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

updating infra conversion job polling timers #18597

Merged
merged 2 commits into from
Mar 29, 2019
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
6 changes: 3 additions & 3 deletions app/models/infra_conversion_job.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class InfraConversionJob < Job
def self.create_job(options)
# TODO: from settings/user plan settings
options[:conversion_polling_interval] ||= 60 # in seconds
options[:poll_conversion_max] ||= 24 * 60 # i.e. default 24 hour (with 60s per-interval)
options[:poll_post_stage_max] ||= 30 # i.e. default 30 minutes
options[:conversion_polling_interval] ||= Settings.transformation.limits.conversion_polling_interval # in seconds
options[:poll_conversion_max] ||= Settings.transformation.limits.poll_conversion_max
options[:poll_post_stage_max] ||= Settings.transformation.limits.poll_post_stage_max
super(name, options)
end

Expand Down
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,9 @@
:max_concurrent_tasks_per_host: 10
:cpu_limit_per_host: unlimited
:network_limit_per_host: unlimited
:conversion_polling_interval: 15 # in seconds
:poll_conversion_max: 86400 # i.e. default 24 hours (15s per-interval)
:poll_post_stage_max: 25200 # i.e. default 7 hours (15s per-interval)
:ui:
:mark_translated_strings: false
:url:
Expand Down
12 changes: 7 additions & 5 deletions spec/models/infra_conversion_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
end

context 'operations' do
let(:poll_interval) { Settings.transformation.limits.conversion_polling_interval }

before do
allow(job).to receive(:migration_task).and_return(task)
end
Expand Down Expand Up @@ -106,15 +108,15 @@
it 'to poll_conversion when migration_task.options[:virtv2v_wrapper] is nil' do
task.options[:virtv2v_wrapper] = nil
Timecop.freeze(2019, 2, 6) do
expect(job).to receive(:queue_signal).with(:poll_conversion, :deliver_on => Time.now.utc + 60)
expect(job).to receive(:queue_signal).with(:poll_conversion, :deliver_on => Time.now.utc + poll_interval)
job.signal(:poll_conversion)
end
end

it 'to poll_conversion when migration_task.options[:virtv2v_wrapper][:state_file] is nil' do
task.options[:virtv2v_wrapper] = {'state_file' => nil}
Timecop.freeze(2019, 2, 6) do
expect(job).to receive(:queue_signal).with(:poll_conversion, :deliver_on => Time.now.utc + 60)
expect(job).to receive(:queue_signal).with(:poll_conversion, :deliver_on => Time.now.utc + poll_interval)
job.signal(:poll_conversion)
end
end
Expand All @@ -129,7 +131,7 @@
task.options[:virtv2v_status] = 'active'
Timecop.freeze(2019, 2, 6) do
expect(task).to receive(:get_conversion_state)
expect(job).to receive(:queue_signal).with(:poll_conversion, :deliver_on => Time.now.utc + 60)
expect(job).to receive(:queue_signal).with(:poll_conversion, :deliver_on => Time.now.utc + poll_interval)
job.signal(:poll_conversion)
end
end
Expand Down Expand Up @@ -167,7 +169,7 @@
it 'to poll_post_stage when signaled :start_post_stage' do
job.state = 'running'
Timecop.freeze(2019, 2, 6) do
expect(job).to receive(:queue_signal).with(:poll_post_stage, :deliver_on => Time.now.utc + 60)
expect(job).to receive(:queue_signal).with(:poll_post_stage, :deliver_on => Time.now.utc + poll_interval)
job.signal(:start_post_stage)
end
end
Expand All @@ -181,7 +183,7 @@
it 'to poll_post_stage when migration_task.state is not finished' do
task.state = 'not-finished'
Timecop.freeze(2019, 2, 6) do
expect(job).to receive(:queue_signal).with(:poll_post_stage, :deliver_on => Time.now.utc + 60)
expect(job).to receive(:queue_signal).with(:poll_post_stage, :deliver_on => Time.now.utc + poll_interval)
job.signal(:poll_post_stage)
end
end
Expand Down