Skip to content

Commit

Permalink
simplify schedule_every case when first_in is the interval
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Oct 14, 2019
1 parent b61deda commit 0bc1014
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions app/models/miq_schedule_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,27 @@ def schedules_for_all_roles

scheduler.schedule_every(
every,
:first_in => every,
:tags => [:vmdb_appliance_log_config, schedule_category]
) { enqueue(:vmdb_appliance_log_config) }

# Schedule - Log current database statistics and bloat
every = worker_settings[:log_database_statistics_interval]
scheduler.schedule_every(
every,
:first_in => every,
:tags => [:log_all_database_statistics, schedule_category]
) { enqueue(:vmdb_database_log_all_database_statistics) }

# Schedule - Update Server Statistics
every = worker_settings[:server_stats_interval]
scheduler.schedule_every(
every,
:first_in => every,
:tags => [:status_update, schedule_category]
) { enqueue(:miq_server_status_update) }

# Schedule - Log Server and Worker Statistics
every = worker_settings[:server_log_stats_interval]
scheduler.schedule_every(
every,
:first_in => every,
:tags => [:log_status, schedule_category]
) { enqueue(:miq_server_worker_log_status) }

Expand Down Expand Up @@ -134,27 +130,27 @@ def schedules_for_scheduler_role
scheduler = scheduler_for(:scheduler)
# Schedule - Check for timed out jobs
every = worker_settings[:job_timeout_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:job_check_jobs_for_timeout)
end

# Schedule - Check for retired items and start retirement
# TODO: remove redundant settings in follow-up pr
every = [worker_settings[:service_retired_interval], worker_settings[:vm_retired_interval], worker_settings[:orchestration_stack_retired_interval]].min
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:retirement_check)
end

# Schedule - Periodic validation of authentications
every = worker_settings[:authentication_check_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
# Queue authentication checks for CIs with credentials
enqueue(:host_authentication_check_schedule)
enqueue(:ems_authentication_check_schedule)
end

every = worker_settings[:drift_state_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:drift_state_purge_timer)
end

Expand All @@ -169,7 +165,7 @@ def schedules_for_scheduler_role
# Schedule - Check for rogue EVM snapshots
every = worker_settings[:evm_snapshot_interval]
job_not_found_delay = worker_settings[:evm_snapshot_delete_delay_for_job_not_found]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue([:job_check_for_evm_snapshots, job_not_found_delay])
end

Expand All @@ -193,37 +189,37 @@ def schedules_for_scheduler_role

# Schedule - Prune old reports Timer
every = worker_settings[:report_result_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:miq_report_result_purge_timer)
end

every = worker_settings[:container_entities_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:archived_entities_purge_timer)
end

every = worker_settings[:binary_blob_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:binary_blob_purge_timer)
end

every = worker_settings[:notifications_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:notification_purge_timer)
end

every = worker_settings[:task_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:task_purge_timer)
end

every = worker_settings[:compliance_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:compliance_purge_timer)
end

every = worker_settings[:vim_performance_states_purge_interval]
scheduler.schedule_every(every, :first_in => every) do
scheduler.schedule_every(every) do
enqueue(:vim_performance_states_purge_timer)
end

Expand All @@ -240,7 +236,7 @@ def schedules_for_scheduler_role
) { enqueue(:storage_scan_timer) }

schedule_settings_for_ems_refresh.each do |klass, local_every|
scheduler.schedule_every(local_every, :first_in => local_every) do
scheduler.schedule_every(local_every) do
enqueue([:ems_refresh_timer, klass])
end
end
Expand Down

0 comments on commit 0bc1014

Please sign in to comment.