Skip to content

Commit

Permalink
Merge pull request ManageIQ#19153 from d-m-u/rufus_upgrade
Browse files Browse the repository at this point in the history
Update rufus-scheduler to 3.6
  • Loading branch information
Fryguy authored Aug 16, 2019
2 parents a6242cb + 5951553 commit a8aee20
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
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) }

# 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
# 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

0 comments on commit a8aee20

Please sign in to comment.