Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions alts/shared/utils/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@ def read_and_cleanup_temp_log_files(
return out, err


def check_for_error_string(stage_data: dict) -> bool:
def check_for_error_string(stderr: str) -> bool:
"""
Checks if we encounter errors during testing that worth keepin VM alive.

Parameters
----------
stage_data: dict
stderr: str

Returns
-------
bool
True if we encounter any error from the list. False otherwise
"""
err = stage_data.get('stderr', '')
if any(error_str in err for error_str in ERROR_STRINGS):
if stderr and any(error_str in stderr for error_str in ERROR_STRINGS):
return True
return False
9 changes: 3 additions & 6 deletions alts/worker/runners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,11 +1555,6 @@ def setup(self, skip_provision: bool = False):

def teardown(self, publish_artifacts: bool = True):
try:
if not self.vm_alive:
for _, stage_data in self.artifacts.items():
self.vm_alive = check_for_error_string(stage_data)
for _, inner_data in stage_data.items():
self.vm_alive = check_for_error_string(inner_data)
self.stop_env()
except Exception as e:
self._logger.exception('Error while stop environment: %s', e)
Expand Down Expand Up @@ -1674,7 +1669,7 @@ def __init__(
self._tests_dir = CONFIG.tests_base_dir
self._ssh_client: Optional[Union[AsyncSSHClient, LongRunSSHClient]] = None
self._vm_ip = None
self._vm_alive = vm_alive
self.vm_alive = vm_alive
self.start_env_failed = False

def _wait_for_ssh(self, retries=60):
Expand Down Expand Up @@ -1762,6 +1757,8 @@ def start_env(self):
final_exit_code = exit_code or ssh_exit_code
final_stdout = f'{stdout}\n\n{ssh_stdout}'
final_stderr = f'{stderr}\n\n{ssh_stderr}'
if not self.vm_alive:
self.vm_alive = check_for_error_string(final_stderr)
return final_exit_code, final_stdout, final_stderr

def setup(self, skip_provision: bool = False):
Expand Down
2 changes: 1 addition & 1 deletion alts/worker/runners/opennebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _stop_env(self):
)
self._logger.warning(err_msg)
return 0, err_msg, ''
if self._vm_alive:
if self.vm_alive:
return 0, "WARNING: VM won't be destroyed because vm_alive=True was given", ""
stop_exit_code, stop_out, stop_err = super()._stop_env()
if stop_exit_code == 0:
Expand Down
Loading