From d6bf5b53de0ea899ed6a3d7d41e5f2b86ea36a2c Mon Sep 17 00:00:00 2001 From: d-m-u Date: Wed, 14 Aug 2019 16:35:17 -0400 Subject: [PATCH 1/5] schedule_every needs :first_in for tagging to work properly --- app/models/miq_schedule_worker/runner.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/miq_schedule_worker/runner.rb b/app/models/miq_schedule_worker/runner.rb index 66e51e603b2..b63a240dd50 100644 --- a/app/models/miq_schedule_worker/runner.rb +++ b/app/models/miq_schedule_worker/runner.rb @@ -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] From f730926b822a09d080df8fa98b03478ad0002182 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Wed, 14 Aug 2019 16:36:00 -0400 Subject: [PATCH 2/5] frequency was removed taken out in https://github.com/jmettraux/rufus-scheduler/commit/ba25015f9442a7cdc0040a453dccdf778204ff87#diff-5d7d9fcb70b7c4ad09e1fa4b2cd82591 --- spec/models/miq_schedule_worker/scheduler_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/miq_schedule_worker/scheduler_spec.rb b/spec/models/miq_schedule_worker/scheduler_spec.rb index 2db3fd683ce..c32065b7b2f 100644 --- a/spec/models/miq_schedule_worker/scheduler_spec.rb +++ b/spec/models/miq_schedule_worker/scheduler_spec.rb @@ -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 From fa9ba1a47db65352939303206add05b4811a341d Mon Sep 17 00:00:00 2001 From: d-m-u Date: Thu, 15 Aug 2019 08:28:10 -0400 Subject: [PATCH 3/5] EoTime does not handle durations EoTime can take numerics: https://github.com/floraison/et-orbi/blob/master/lib/et-orbi/time.rb#L292 --- spec/models/miq_schedule_worker/jobs_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/miq_schedule_worker/jobs_spec.rb b/spec/models/miq_schedule_worker/jobs_spec.rb index d67afde2d37..2f329869aa2 100644 --- a/spec/models/miq_schedule_worker/jobs_spec.rb +++ b/spec/models/miq_schedule_worker/jobs_spec.rb @@ -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, {}) From a6e9f20160fdb2940f661742a424bc04074e415a Mon Sep 17 00:00:00 2001 From: d-m-u Date: Thu, 15 Aug 2019 13:10:24 -0400 Subject: [PATCH 4/5] Add initializer for time object compatibility until we can patch --- Gemfile | 3 +++ config/initializers/convert_time_to_eo.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 config/initializers/convert_time_to_eo.rb diff --git a/Gemfile b/Gemfile index 14d373b73d5..632744b6c42 100644 --- a/Gemfile +++ b/Gemfile @@ -77,6 +77,9 @@ gem "sqlite3", "~>1.3.0", :require => false gem "sys-filesystem", "~>1.2.0" gem "terminal", :require => false +# temporary inclusion till we can get ConvertTimeToEoTime patch into upstream +gem "et-orbi" + # Modified gems (forked on Github) gem "ruport", "=1.7.0", :git => "https://github.com/ManageIQ/ruport.git", :tag => "v1.7.0-3" diff --git a/config/initializers/convert_time_to_eo.rb b/config/initializers/convert_time_to_eo.rb new file mode 100644 index 00000000000..7d0f9f10471 --- /dev/null +++ b/config/initializers/convert_time_to_eo.rb @@ -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) From 5951553f7be00302f17872bd7497b6090968dee5 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Thu, 15 Aug 2019 13:27:57 -0400 Subject: [PATCH 5/5] Change rufus version --- Gemfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 632744b6c42..68a96775e54 100644 --- a/Gemfile +++ b/Gemfile @@ -77,9 +77,6 @@ gem "sqlite3", "~>1.3.0", :require => false gem "sys-filesystem", "~>1.2.0" gem "terminal", :require => false -# temporary inclusion till we can get ConvertTimeToEoTime patch into upstream -gem "et-orbi" - # Modified gems (forked on Github) gem "ruport", "=1.7.0", :git => "https://github.com/ManageIQ/ruport.git", :tag => "v1.7.0-3" @@ -194,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"