Skip to content

Commit

Permalink
Don't thrash settings when we only have one server
Browse files Browse the repository at this point in the history
Before this change, a single server would init the settings every
time it was monitored. This causes an unnecessary amount of extra
work in the appliance model where we will always have only a single
server.

To avoid this, return from #impersonate_server if we already are
the requested server, and only reset the caches if we changed servers.
  • Loading branch information
carbonin committed Jan 21, 2020
1 parent 34648e1 commit 1362205
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/workers/evm_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,20 @@ def start_workers
# contents of the global ::Settings constant.
######################################################################
def for_each_server
initial_server = @server
servers_to_monitor.each do |s|
impersonate_server(s)
yield
end
ensure
clear_server_caches
clear_server_caches if @server != initial_server
end

def impersonate_server(s)
return if s == @server

# generic log message to say we're switching servers?

MiqServer.my_guid = s.guid
# It is important that we continue to use the same server instance here.
# A lot of "global" state is stored in instance variables on the server.
Expand Down

0 comments on commit 1362205

Please sign in to comment.