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

Update rufus-scheduler to 3.6 #19153

Merged
merged 5 commits into from
Aug 16, 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: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ group :graphql_api, :manageiq_default do
end

group :scheduler, :manageiq_default do
# Modified gems (forked on Github)
gem "rufus-scheduler", "=3.1.10.2", :git => "https://github.com/ManageIQ/rufus-scheduler.git", :require => false, :tag => "v3.1.10-2"
gem "rufus-scheduler"
end
# rufus has et-orbi dependency
# this is temporary inclusion till we can get ConvertTimeToEoTime patch into upstream:
gem "et-orbi"

group :seed, :manageiq_default do
manageiq_plugin "manageiq-content"
Expand Down
16 changes: 10 additions & 6 deletions app/models/miq_schedule_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ def schedules_for_all_roles
# Schedule - Log current system configuration
every = worker_settings[:log_active_configuration_interval]

scheduler.schedule_every(every, :tags => [:vmdb_appliance_log_config, schedule_category]) do
enqueue(:vmdb_appliance_log_config)
end
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, :tags => [:log_all_database_statistics, schedule_category]) do
enqueue(:vmdb_database_log_all_database_statistics)
end
scheduler.schedule_every(
every,
:first_in => every,
:tags => [:log_all_database_statistics, schedule_category]
) { enqueue(:vmdb_database_log_all_database_statistics) }
jrafanie marked this conversation as resolved.
Show resolved Hide resolved

# Schedule - Update Server Statistics
every = worker_settings[:server_stats_interval]
Expand Down
12 changes: 12 additions & 0 deletions config/initializers/convert_time_to_eo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# temporary hack for when/if we can get patch accepted upscream
jrafanie marked this conversation as resolved.
Show resolved Hide resolved
# et-orbi doesn't support comparisons of EoTime in the scheduler with user provided Time objects
# see https://github.com/ManageIQ/manageiq/pull/19153#issuecomment-521719495
module ConvertTimeToEoTime
def ==(*args)
o = EtOrbi.make_time(args.first) if args.first.kind_of?(Time) || args.first.kind_of?(DateTime)
super(o)
end
end

require 'et-orbi'
EtOrbi::EoTime.prepend(ConvertTimeToEoTime)
2 changes: 1 addition & 1 deletion spec/models/miq_schedule_worker/jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
schedule_id = 123
scheduler = Rufus::Scheduler.new
block = -> { "some work" }
rufus_job = Rufus::Scheduler::EveryJob.new(scheduler, 1.hour, {}, block)
rufus_job = Rufus::Scheduler::EveryJob.new(scheduler, 1.hour.to_i, {}, block)

expect(MiqSchedule).to receive(:queue_scheduled_work).with(schedule_id, rufus_job.job_id, 1.hour.from_now.to_i, {})

Expand Down
2 changes: 1 addition & 1 deletion spec/models/miq_schedule_worker/scheduler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
scheduler.schedule_cron("0 0 * * *", :tags => [:a, :b], &work)
job = rufus_scheduler.jobs.first

expect(job.frequency).to eq(1.day)
expect(job.rough_frequency).to eq(1.day.to_i)
expect(job.tags).to match_array(%w(a b))
expect(job.callable).to eq(work)
end
Expand Down