Do not show duplicate or useless dump logs
Another changes: - fix unexpected behavior: Astute has sent huge message instead of string with dump file path; - add ability to not log mcollective result; - remove logging duplication of incoming Astute tasks. Change-Id: Idccf9bd3e57b4c160f077df779f386f656830d38 Closes-Bug: #1534206
This commit is contained in:
parent
f28e110780
commit
d6eb6f7051
|
@ -16,10 +16,15 @@
|
|||
module Astute
|
||||
module Dump
|
||||
def self.dump_environment(ctx, settings)
|
||||
lastdump = settings['lastdump']
|
||||
|
||||
timeout = settings['timeout'] || Astute.config.dump_timeout
|
||||
shell = MClient.new(ctx, 'execute_shell_command', ['master'], check_result=true, timeout=timeout, retries=0)
|
||||
shell = MClient.new(
|
||||
ctx,
|
||||
'execute_shell_command',
|
||||
['master'],
|
||||
check_result=true,
|
||||
settings['timeout'] || Astute.config.dump_timeout,
|
||||
retries=0,
|
||||
enable_result_logging=false
|
||||
)
|
||||
|
||||
upload_file = MClient.new(ctx, 'uploadfile', ['master'])
|
||||
begin
|
||||
|
@ -31,7 +36,7 @@ module Astute
|
|||
:group_owner => 'root',
|
||||
:overwrite => true)
|
||||
|
||||
dump_cmd = "shotgun -c #{config_path} 2>&1 && cat #{lastdump}"
|
||||
dump_cmd = "shotgun -c #{config_path} > /dev/null 2>&1 && cat #{settings['lastdump']}"
|
||||
Astute.logger.debug("Try to execute command: #{dump_cmd}")
|
||||
result = shell.execute(:cmd => dump_cmd).first.results
|
||||
|
||||
|
|
|
@ -24,7 +24,16 @@ module Astute
|
|||
|
||||
attr_accessor :retries
|
||||
|
||||
def initialize(ctx, agent, nodes=nil, check_result=true, timeout=nil, retries=Astute.config.mc_retries)
|
||||
def initialize(
|
||||
ctx,
|
||||
agent,
|
||||
nodes=nil,
|
||||
check_result=true,
|
||||
timeout=nil,
|
||||
retries=Astute.config.mc_retries,
|
||||
enable_result_logging=true
|
||||
)
|
||||
|
||||
@task_id = ctx.task_id
|
||||
@agent = agent
|
||||
@nodes = nodes.map { |n| n.to_s } if nodes
|
||||
|
@ -38,6 +47,7 @@ module Astute
|
|||
# timeout - 20 sec, DDL - not set. Result — 10 sec.
|
||||
@timeout = timeout
|
||||
@retries = retries
|
||||
@enable_result_logging = enable_result_logging
|
||||
initialize_mclient
|
||||
end
|
||||
|
||||
|
@ -55,7 +65,7 @@ module Astute
|
|||
end
|
||||
|
||||
# Enable if needed. In normal case it eats the screen pretty fast
|
||||
log_result(@mc_res, method)
|
||||
log_result(@mc_res, method) if @enable_result_logging
|
||||
|
||||
check_results_with_retries(method, args) if @check_result
|
||||
|
||||
|
@ -79,8 +89,10 @@ module Astute
|
|||
Astute.logger.debug "Retry ##{retry_index} to run mcollective agent on nodes: '#{not_responded.join(',')}'"
|
||||
mc_send :discover, :nodes => not_responded
|
||||
@new_res = mc_send(method, *args)
|
||||
log_result(@new_res, method)
|
||||
|
||||
log_result(@new_res, method) if @enable_result_logging
|
||||
# @new_res can have some nodes which finally responded
|
||||
|
||||
@mc_res += @new_res
|
||||
break if @mc_res.length == @nodes.length
|
||||
retry_index += 1
|
||||
|
|
|
@ -163,8 +163,6 @@ module Astute
|
|||
end
|
||||
|
||||
def dispatch_message(data, service_data=nil)
|
||||
Astute.logger.debug "Dispatching message:\n#{data.pretty_inspect}"
|
||||
|
||||
if Astute.config.fake_dispatch
|
||||
Astute.logger.debug "Fake dispatch"
|
||||
return
|
||||
|
@ -204,7 +202,6 @@ module Astute
|
|||
end
|
||||
|
||||
def parse_data(data)
|
||||
Astute.logger.debug "Got message with payload\n#{data.pretty_inspect}"
|
||||
messages = nil
|
||||
begin
|
||||
messages = JSON.load(data)
|
||||
|
|
|
@ -38,7 +38,7 @@ describe 'dump_environment' do
|
|||
|
||||
it "should upload the config and call execute method with shotgun as cmd" do
|
||||
config_path = '/tmp/dump_config'
|
||||
dump_cmd = "shotgun -c #{config_path} 2>&1 && cat #{settings['lastdump']}"
|
||||
dump_cmd = "shotgun -c #{config_path} > /dev/null 2>&1 && cat #{settings['lastdump']}"
|
||||
rpc_mock.expects(:upload).with({
|
||||
path: config_path,
|
||||
content: settings.to_json,
|
||||
|
@ -67,7 +67,7 @@ describe 'dump_environment' do
|
|||
|
||||
it "non default timeout should be used" do
|
||||
Astute::MClient.stubs(:new).with(ctx, 'uploadfile', ['master'])
|
||||
Astute::MClient.stubs(:new).with(ctx, 'execute_shell_command', ['master'], true, 300, 0)
|
||||
Astute::MClient.stubs(:new).with(ctx, 'execute_shell_command', ['master'], true, 300, 0, false)
|
||||
Astute::Dump.dump_environment(ctx, settings)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue