diff --git a/api_app/service_bus/airlock_request_status_update.py b/api_app/service_bus/airlock_request_status_update.py index 7a2524f7b9..e26f573303 100644 --- a/api_app/service_bus/airlock_request_status_update.py +++ b/api_app/service_bus/airlock_request_status_update.py @@ -29,7 +29,7 @@ async def init_repos(self): self.workspace_repo = await WorkspaceRepository.create(db_client) async def receive_messages(self): - with tracer.start_as_current_span("airlock_receive_messages") as current_span: + with tracer.start_as_current_span("airlock_receive_messages"): while True: try: async with credentials.get_credential_async() as credential: diff --git a/api_app/service_bus/deployment_status_updater.py b/api_app/service_bus/deployment_status_updater.py index f2e1cfd031..b38e138927 100644 --- a/api_app/service_bus/deployment_status_updater.py +++ b/api_app/service_bus/deployment_status_updater.py @@ -38,7 +38,7 @@ def run(self, *args, **kwargs): asyncio.run(self.receive_messages()) async def receive_messages(self): - with tracer.start_as_current_span("deployment_status_receive_messages") as current_span: + with tracer.start_as_current_span("deployment_status_receive_messages"): while True: try: async with credentials.get_credential_async() as credential: diff --git a/api_app/tests_ma/test_db/test_repositories/test_workpaces_repository.py b/api_app/tests_ma/test_db/test_repositories/test_workpaces_repository.py index 3cbd84b431..79b9a5176a 100644 --- a/api_app/tests_ma/test_db/test_repositories/test_workpaces_repository.py +++ b/api_app/tests_ma/test_db/test_repositories/test_workpaces_repository.py @@ -102,7 +102,7 @@ async def test_get_workspace_by_id_queries_db(workspace_repo, workspace): @patch('db.repositories.workspaces.WorkspaceRepository.validate_input_against_template') @patch('core.config.RESOURCE_LOCATION', "useast2") @patch('core.config.TRE_ID', "9876") -async def test_create_workspace_item_creates_a_workspace_with_the_right_values(validate_input_mock, new_cidr_mock, workspace_repo, basic_workspace_request, basic_resource_template): +async def test_create_workspace_item_creates_a_workspace_with_the_right_values(validate_input_mock, new_cidr_mock, workspace_repo, basic_workspace_request, basic_resource_template): workspace_to_create = basic_workspace_request # make sure the input has 'None' for values that we expect to be set workspace_to_create.properties.pop("address_space", None) diff --git a/core/terraform/resource_processor/vmss_porter/cloud-config.yaml b/core/terraform/resource_processor/vmss_porter/cloud-config.yaml index 19356ac929..56a7ff21a2 100644 --- a/core/terraform/resource_processor/vmss_porter/cloud-config.yaml +++ b/core/terraform/resource_processor/vmss_porter/cloud-config.yaml @@ -1,5 +1,5 @@ --- -#cloud-config +# cloud-config package_upgrade: true apt: sources: @@ -79,8 +79,11 @@ runcmd: # (https://microsoft.github.io/AzureTRE/troubleshooting-faq/troubleshooting-rp/#Logs) - printf '\nalias dlf="docker logs --since 1m --follow"' >> /etc/bash.bashrc - printf '\nalias dlf1='\''dlf $(docker ps -q | head -n 1)'\''' >> /etc/bash.bashrc - - printf '\nalias rpstatus='\''tmux new-session -d "watch docker ps"; tmux split-window -p 100 -v "docker logs --since 1m --follow resource_processor1"; tmux split-window -v -p 90; tmux -2 attach-session -d'\''\n' >> /etc/bash.bashrc - + - > + printf '\nalias rpstatus='\''tmux new-session -d "watch docker ps"; \ + tmux split-window -p 100 -v "docker logs --since 1m --follow resource_processor1"; \ + tmux split-window -v -p 90; \ + tmux -2 attach-session -d'\''\n' >> /etc/bash.bashrc - export DEBIAN_FRONTEND=noninteractive - az cloud set --name ${azure_environment} - az login --identity -u ${vmss_msi_id} diff --git a/resource_processor/shared/logging.py b/resource_processor/shared/logging.py index 9d942bd21e..aeedf39f13 100644 --- a/resource_processor/shared/logging.py +++ b/resource_processor/shared/logging.py @@ -74,7 +74,6 @@ def initialize_logging() -> logging.Logger: elif logging_level == "ERROR": logging_level = logging.ERROR - if os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"): configure_azure_monitor( logger_name="azuretre_resource_processor", diff --git a/resource_processor/tests_rp/test_logging.py b/resource_processor/tests_rp/test_logging.py index 516d189248..3f38a57582 100644 --- a/resource_processor/tests_rp/test_logging.py +++ b/resource_processor/tests_rp/test_logging.py @@ -2,11 +2,13 @@ import logging from shared.logging import shell_output_logger + @patch("shared.logging.logger") def test_shell_output_logger_empty_console_output(mock_logger): shell_output_logger("", "prefix", logging.DEBUG) mock_logger.debug.assert_called_once_with("shell console output is empty.") + @patch("shared.logging.logger") def test_shell_output_logger_image_not_present_locally(mock_logger): console_output = "Unable to find image 'test_image' locally\nexecution completed successfully!" @@ -14,12 +16,14 @@ def test_shell_output_logger_image_not_present_locally(mock_logger): mock_logger.debug.assert_called_with("Image not present locally, removing text from console output.") mock_logger.log.assert_called_with(logging.INFO, "prefix execution completed successfully!") + @patch("shared.logging.logger") def test_shell_output_logger_execution_completed_successfully(mock_logger): console_output = "execution completed successfully!" shell_output_logger(console_output, "prefix", logging.DEBUG) mock_logger.log.assert_called_with(logging.INFO, "prefix execution completed successfully!") + @patch("shared.logging.logger") def test_shell_output_logger_normal_case(mock_logger): console_output = "Some logs" diff --git a/resource_processor/vmss_porter/runner.py b/resource_processor/vmss_porter/runner.py index 3ff6829cf3..12a12bdbfe 100644 --- a/resource_processor/vmss_porter/runner.py +++ b/resource_processor/vmss_porter/runner.py @@ -108,10 +108,12 @@ async def run_porter(command, config: dict): *command ] - proc = await asyncio.create_subprocess_shell(''.join(command), + proc = await asyncio.create_subprocess_shell( + ''.join(command), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, - env=config["porter_env"]) + env=config["porter_env"] + ) stdout, stderr = await proc.communicate() logger.debug(f'run porter exited with {proc.returncode}')