Skip to content

Commit

Permalink
Merge pull request #20072 from jrafanie/eager-load-api-collection-cla…
Browse files Browse the repository at this point in the history
…sses-in-web-service-worker

Eager load collection constants to avoid constant loading problems.

(cherry picked from commit 747ab52)

https://bugzilla.redhat.com/show_bug.cgi?id=1823849
  • Loading branch information
kbrock authored and simaishi committed Apr 15, 2020
1 parent fcfcd4b commit 91899e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/miq_web_service_worker.rb
Expand Up @@ -26,4 +26,9 @@ def self.bundler_groups
def self.kill_priority
MiqWorkerType::KILL_PRIORITY_WEB_SERVICE_WORKERS
end

def self.preload_for_worker_role
super
Api::ApiConfig.collections.each { |_k, v| v.klass.try(:constantize).try(:descendants) }
end
end
8 changes: 8 additions & 0 deletions spec/models/miq_web_server_worker_spec.rb
@@ -0,0 +1,8 @@
RSpec.describe MiqWebServiceWorker do
it "preload_for_worker_role autoloads api collection classes and descendants" do
allow(EvmDatabase).to receive(:seeded_primordially?).and_return(true)
expect(MiqWebServiceWorker).to receive(:configure_secret_token)
MiqWebServiceWorker.preload_for_worker_role
expect(defined?(ServiceAnsibleTower)).to be_truthy
end
end

0 comments on commit 91899e2

Please sign in to comment.