Skip to content

Commit

Permalink
Pass the server receiving the synchronize_logs message.
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1174855

If initiated from a zone, we want to create one miq_queue and miq_tasks row for each server in the Zone.

Without this change, it will create N number of rows for the server receiving the web request, MiqServer.my_server, where N is the number of active servers in the zone.  It will never request logs for the other servers in the zone.

This is fairly easy to recreate:
1) Setup a Zone with 2 or more "active" appliances (miq_servers)
2) Request log collection for the Zone
3) Look at the log depot and find only the logs from the server receiving the web request.
  • Loading branch information
jrafanie committed Dec 23, 2014
1 parent 4511cac commit e3fd51d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 3 additions & 1 deletion vmdb/app/models/miq_server/log_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def _post_my_logs(options)
end

def synchronize_logs(*args)
LogFile.logs_from_server(*args)
options = args.extract_options!
args << self unless args.last.kind_of?(self.class)
LogFile.logs_from_server(*args, options)
end

def last_log_sync_on
Expand Down
20 changes: 19 additions & 1 deletion vmdb/spec/models/miq_server/log_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

describe MiqServer do
context "LogManagement" do
before do
_, @miq_server, @zone = EvmSpecHelper.create_guid_miq_server_zone
@miq_server2 = FactoryGirl.create(:miq_server, :zone => @zone)
end

context "#synchronize_logs" do
it "passes along server override" do
@miq_server.synchronize_logs("system", @miq_server2)
expect(MiqTask.first.miq_server_id).to eql @miq_server2.id
expect(MiqQueue.first.args.first[:id]).to eql @miq_server2.id
end

it "passes 'self' server if no server arg" do
@miq_server2.synchronize_logs("system")
expect(MiqTask.first.miq_server_id).to eql @miq_server2.id
expect(MiqQueue.first.args.first[:id]).to eql @miq_server2.id
end
end

context "#get_log_depot_settings" do
let(:depot_hash) do
{:uri => uri,
Expand All @@ -15,7 +34,6 @@
let(:uri) { "smb://server/share" }

before do
_, @miq_server, @zone = EvmSpecHelper.create_guid_miq_server_zone
depot.update_authentication(:default => {:userid => "user", :password => "pass"})
end

Expand Down
6 changes: 3 additions & 3 deletions vmdb/spec/models/shared_examples/log_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
let(:instance) { instance_variable_get("@#{type}") }

it "#{type.camelize} no args" do
LogFile.should_receive(:logs_from_server).with()
LogFile.should_receive(:logs_from_server).with(MiqServer.my_server, {})

instance.synchronize_logs
end

it "#{type.camelize} with options" do
LogFile.should_receive(:logs_from_server).with(:only_current => true)
LogFile.should_receive(:logs_from_server).with(MiqServer.my_server, :only_current => true)

instance.synchronize_logs(:only_current => true)
end

it "#{type.camelize} user with options" do
LogFile.should_receive(:logs_from_server).with("test", :only_current => false)
LogFile.should_receive(:logs_from_server).with("test", MiqServer.my_server, :only_current => false)

instance.synchronize_logs("test", :only_current => false)
end
Expand Down

0 comments on commit e3fd51d

Please sign in to comment.