Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 11 additions & 6 deletions alts/worker/runners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def __init__(
package_channel: Optional[str] = None,
test_configuration: Optional[dict] = None,
test_flavor: Optional[Dict[str, str]] = None,
vm_alive: bool = False,
verbose: bool = False,
):
# Environment ID and working directory preparation
Expand Down Expand Up @@ -279,6 +280,7 @@ def __init__(
self._stats = {}
self._verbose = verbose
self.package_channel = package_channel
self.vm_alive = vm_alive

@property
def artifacts(self):
Expand Down Expand Up @@ -1634,6 +1636,7 @@ def __init__(
package_channel: Optional[str] = None,
test_configuration: Optional[dict] = None,
test_flavor: Optional[Dict[str, str]] = None,
vm_alive: bool = False,
verbose: bool = False,
):
super().__init__(
Expand All @@ -1652,6 +1655,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

def _wait_for_ssh(self, retries=60):
ansible = local[self.ansible_binary]
Expand Down Expand Up @@ -1746,12 +1750,13 @@ def setup(self, skip_provision: bool = False):
self._ssh_client = LongRunSSHClient(**params)

def teardown(self, publish_artifacts: bool = True):
if self._ssh_client:
try:
self._ssh_client.close()
except:
pass
super().teardown(publish_artifacts=publish_artifacts)
if not self._vm_alive:
if self._ssh_client:
try:
self._ssh_client.close()
except:
pass
super().teardown(publish_artifacts=publish_artifacts)

def exec_command(self, *args, **kwargs) -> Tuple[int, str, str]:
command = ' '.join(args)
Expand Down
2 changes: 2 additions & 0 deletions alts/worker/runners/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(
dist_arch: str = 'x86_64',
test_configuration: Optional[dict] = None,
test_flavor: Optional[Dict[str, str]] = None,
vm_alive: bool = False,
artifacts_uploader: Optional[BaseLogsUploader] = None,
package_channel: Optional[str] = None,
verbose: bool = False,
Expand Down Expand Up @@ -97,6 +98,7 @@ def __init__(
dist_arch=dist_arch,
test_configuration=test_configuration,
test_flavor=test_flavor,
vm_alive=vm_alive,
artifacts_uploader=artifacts_uploader,
package_channel=package_channel,
verbose=verbose,
Expand Down
2 changes: 2 additions & 0 deletions alts/worker/runners/opennebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
package_channel: Optional[str] = None,
test_configuration: Optional[dict] = None,
test_flavor: Optional[Dict[str, str]] = None,
vm_alive: bool = False,
verbose: bool = False,
):
super().__init__(
Expand All @@ -62,6 +63,7 @@ def __init__(
package_channel=package_channel,
test_configuration=test_configuration,
test_flavor=test_flavor,
vm_alive= vm_alive,
verbose=verbose,
)
user = CONFIG.opennebula_config.username
Expand Down
3 changes: 2 additions & 1 deletion alts/worker/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def set_artifacts_when_stage_has_unexpected_exception(
'dist_arch': task_params.get('dist_arch', 'x86_64'),
'package_channel': task_params.get('package_channel', 'beta'),
'test_configuration': task_params.get('test_configuration', {}),
'test_flavor': task_params.get('test_flavor', {})
'test_flavor': task_params.get('test_flavor', {}),
'vm_alive': task_params.get('vm_alive')
}

runner_class = RUNNER_MAPPING[task_params['runner_type']]
Expand Down