diff options
author | 2020-08-20 17:51:17 -0400 | |
---|---|---|
committer | 2020-08-24 17:31:19 +0000 | |
commit | 0f0b5a02d777482e0011b3bc7276d410ee643ae8 (patch) | |
tree | 16ca3faa0271f29e9f4ca883442ce0885c27f507 /ms/command-executor/src/main/python/command_executor_server.py | |
parent | 400aed4ddd71657b6c81bb6ec95b1fac2ad63e8e (diff) |
Add request IDs in command-executor log
* Update gRPC interface to handle SubRequestID and Originator ID
* Update command-executor log format to handle request IDs in the log statement
* Add SubRequest ID and Originator ID in BP log statement
Issue-ID: CCSDK-2687
Change-Id: If261bb0912df5800ed2fc65371c5ee784d6a45fb
Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca>
Diffstat (limited to 'ms/command-executor/src/main/python/command_executor_server.py')
-rw-r--r-- | ms/command-executor/src/main/python/command_executor_server.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/ms/command-executor/src/main/python/command_executor_server.py b/ms/command-executor/src/main/python/command_executor_server.py index aa666ee24..175ddc7d3 100644 --- a/ms/command-executor/src/main/python/command_executor_server.py +++ b/ms/command-executor/src/main/python/command_executor_server.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -# Copyright (C) 2019 Bell Canada. +# Copyright (C) 2019 - 2020 Bell Canada. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,32 +29,34 @@ class CommandExecutorServer(CommandExecutor_pb2_grpc.CommandExecutorServiceServi def prepareEnv(self, request, context): blueprint_id = utils.get_blueprint_id(request) - self.logger.info("{} - Received prepareEnv request".format(blueprint_id)) - self.logger.info(request) + extra = utils.getExtraLogData(request) + self.logger.info("{} - Received prepareEnv request".format(blueprint_id), extra=extra) + self.logger.info(request, extra=extra) handler = CommandExecutorHandler(request) prepare_env_response = handler.prepare_env(request) if prepare_env_response[utils.CDS_IS_SUCCESSFUL_KEY]: - self.logger.info("{} - Package installation logs {}".format(blueprint_id, prepare_env_response[utils.RESULTS_LOG_KEY])) + self.logger.info("{} - Package installation logs {}".format(blueprint_id, prepare_env_response[utils.RESULTS_LOG_KEY]), extra=extra) else: - self.logger.info("{} - Failed to prepare python environment. {}".format(blueprint_id, prepare_env_response[utils.ERR_MSG_KEY])) - self.logger.info("Prepare Env Response returned : %s" % prepare_env_response) + self.logger.info("{} - Failed to prepare python environment. {}".format(blueprint_id, prepare_env_response[utils.ERR_MSG_KEY]), extra=extra) + self.logger.info("Prepare Env Response returned : %s" % prepare_env_response, extra=extra) return utils.build_grpc_response(request.requestId, prepare_env_response) def executeCommand(self, request, context): blueprint_id = utils.get_blueprint_id(request) - self.logger.info("{} - Received executeCommand request".format(blueprint_id)) + extra = utils.getExtraLogData(request) + self.logger.info("{} - Received executeCommand request".format(blueprint_id), extra=extra) if os.environ.get('CE_DEBUG','false') == "true": - self.logger.info(request) + self.logger.info(request, extra=extra) handler = CommandExecutorHandler(request) exec_cmd_response = handler.execute_command(request) if exec_cmd_response[utils.CDS_IS_SUCCESSFUL_KEY]: - self.logger.info("{} - Execution finished successfully.".format(blueprint_id)) + self.logger.info("{} - Execution finished successfully.".format(blueprint_id), extra=extra) else: - self.logger.info("{} - Failed to executeCommand. {}".format(blueprint_id, exec_cmd_response[utils.RESULTS_LOG_KEY])) + self.logger.info("{} - Failed to executeCommand. {}".format(blueprint_id, exec_cmd_response[utils.RESULTS_LOG_KEY]), extra=extra) ret = utils.build_grpc_response(request.requestId, exec_cmd_response) - self.logger.info("Payload returned : {}".format(exec_cmd_response)) + self.logger.info("Payload returned : {}".format(exec_cmd_response), extra=extra) return ret
\ No newline at end of file |