Skip to content

Commit

Permalink
Add check to log jsonrpc request/response (ansible#54606)
Browse files Browse the repository at this point in the history
Fixes ansible#54605

Add check in ansible-connection to check if persistent
log message is enabled, if yes log the jsonrpc request
in log file.

With the current approach the _messages queue in `NetworkConnectionBase`
is getting overwritten and response for `pop_message` api inovcation from
ansible-connection is not recevied at the module side.
  • Loading branch information
ganeshrn authored Apr 3, 2019
1 parent 3694711 commit d100fae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/ansible-connection
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,18 @@ class ConnectionProcess(object):
data = recv_data(s)
if not data:
break
self.connection._log_messages("jsonrpc request: %s" % data)
log_messages = self.connection.get_option('persistent_log_messages')

if log_messages:
display.display("jsonrpc request: %s" % data, log_only=True)

signal.alarm(self.connection.get_option('persistent_command_timeout'))
resp = self.srv.handle_request(data)
signal.alarm(0)

self.connection._log_messages("jsonrpc response: %s" % resp)
if log_messages:
display.display("jsonrpc response: %s" % resp, log_only=True)

send_data(s, to_bytes(resp))

s.close()
Expand Down

0 comments on commit d100fae

Please sign in to comment.