File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 6363 'publickey' ,
6464]
6565
66+ ERROR_STRINGS = (
67+ 'Error: Failed to wait virtual machine to be in RUNNING state' ,
68+ )
69+
6670
6771class TapStatusEnum (IntEnum ):
6872 FAILED = 0
Original file line number Diff line number Diff line change 22from tempfile import NamedTemporaryFile
33from typing import IO , Tuple
44
5+ from alts .shared .constants import ERROR_STRINGS
56
67def get_temp_log_files (prefix : str ) -> Tuple [IO , IO ]:
78 temp_file_kwargs = {
@@ -27,3 +28,22 @@ def read_and_cleanup_temp_log_files(
2728 file .close ()
2829 os .unlink (file .name )
2930 return out , err
31+
32+
33+ def check_for_error_string (stage_data : dict ) -> bool :
34+ """
35+ Checks if we encounter errors during testing that worth keepin VM alive.
36+
37+ Parameters
38+ ----------
39+ stage_data: dict
40+
41+ Returns
42+ -------
43+ bool
44+ True if we encounter any error from the list. False otherwise
45+ """
46+ err = stage_data .get ('stderr' , '' )
47+ if any (error_str in err for error_str in ERROR_STRINGS ):
48+ return True
49+ return False
Original file line number Diff line number Diff line change 5757from alts .shared .utils .log_utils import (
5858 get_temp_log_files ,
5959 read_and_cleanup_temp_log_files ,
60+ check_for_error_string ,
6061)
6162from alts .shared .utils .plumbum_utils import wait_bg_process
6263from alts .worker import CONFIG , RESOURCES_DIR
@@ -1554,6 +1555,11 @@ def setup(self, skip_provision: bool = False):
15541555
15551556 def teardown (self , publish_artifacts : bool = True ):
15561557 try :
1558+ if not self .vm_alive :
1559+ for _ , stage_data in self .artifacts .items ():
1560+ self .vm_alive = check_for_error_string (stage_data )
1561+ for _ , inner_data in stage_data .items ():
1562+ self .vm_alive = check_for_error_string (inner_data )
15571563 self .stop_env ()
15581564 except Exception as e :
15591565 self ._logger .exception ('Error while stop environment: %s' , e )
You can’t perform that action at this time.
0 commit comments