From 158857c9d8b2c1889adc470da8ad09aef8b8a1e0 Mon Sep 17 00:00:00 2001 From: Lili Deng Date: Tue, 20 Aug 2024 12:32:52 +0800 Subject: [PATCH] save_console_log: catch ChunkedEncodingError --- lisa/sut_orchestrator/azure/common.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lisa/sut_orchestrator/azure/common.py b/lisa/sut_orchestrator/azure/common.py index 684f71659..2db3a0a9a 100644 --- a/lisa/sut_orchestrator/azure/common.py +++ b/lisa/sut_orchestrator/azure/common.py @@ -86,6 +86,7 @@ from dataclasses_json import dataclass_json from marshmallow import fields, validate from msrestazure.azure_cloud import AZURE_PUBLIC_CLOUD, Cloud # type: ignore from PIL import Image, UnidentifiedImageError +from requests.exceptions import ChunkedEncodingError from retry import retry from lisa import feature, schema, search_space @@ -2025,12 +2026,22 @@ def save_console_log( ) screenshot_raw_name.unlink() - log_response = requests.get(diagnostic_data.serial_console_log_blob_uri, timeout=60) - if log_response.status_code == 404: - log.debug( - "The serial console is not generated. " - "The reason may be the VM is not started." + try: + log_response = requests.get( + diagnostic_data.serial_console_log_blob_uri, timeout=60 ) + if log_response.status_code == 404: + log.debug( + "The serial console is not generated. " + "The reason may be the VM is not started." + ) + except ChunkedEncodingError as ex: + log.debug(f"ChunkedEncodingError occurred: {ex}") + return b"" + except Exception as ex: + log.debug(f"Failed to save console log: {ex}") + return b"" + return log_response.content