Skip to content

Commit

Permalink
Merge pull request #13976 from jrafanie/rescue_worker_sync_workers
Browse files Browse the repository at this point in the history
Rescue worker class sync_workers exceptions and move on
(cherry picked from commit aaf7406)

https://bugzilla.redhat.com/show_bug.cgi?id=1429648
  • Loading branch information
gtanzillo authored and simaishi committed Mar 7, 2017
1 parent 787ebd5 commit 15181e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/models/miq_server/worker_management/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ def worker_not_responding(w)
def sync_workers
result = {}
self.class.monitor_class_names.each do |class_name|
c = class_name.constantize
result[c.name] = c.sync_workers
result[c.name][:adds].each { |pid| worker_add(pid) unless pid.nil? }
begin
c = class_name.constantize
result[c.name] = c.sync_workers
result[c.name][:adds].each { |pid| worker_add(pid) unless pid.nil? }
rescue => error
_log.error("Failed to sync_workers for class: #{class_name}")
_log.log_backtrace(error)
next
end
end
result
end
Expand Down
10 changes: 10 additions & 0 deletions spec/models/miq_server/worker_management/monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@
server.reload
expect(server.miq_workers.first.id).to eq(worker.id)
end

context "#sync_workers" do
let(:server) { EvmSpecHelper.local_miq_server }
it "rescues exceptions and moves on" do
allow(MiqServer).to receive(:monitor_class_names).and_return(%w(MiqGenericWorker MiqPriorityWorker))
allow(MiqGenericWorker).to receive(:sync_workers).and_raise
expect(MiqPriorityWorker).to receive(:sync_workers).and_return(:adds => [123])
expect(server.sync_workers).to eq("MiqPriorityWorker"=>{:adds=>[123]})
end
end
end
end

0 comments on commit 15181e4

Please sign in to comment.