diff --git a/badge_server/main.py b/badge_server/main.py index 100ea620..db63e880 100644 --- a/badge_server/main.py +++ b/badge_server/main.py @@ -135,7 +135,7 @@ def _get_all_results_from_cache(package_name, commit_number=None): if self_compat_res['py3']['status'] == 'SUCCESS' and \ google_compat_res['py3']['status'] == 'SUCCESS' and \ dependency_res['status'] == 'UP_TO_DATE': - status = 'SUCCESS' + status = 'SUCCESS' elif 'CALCULATING' in ( self_compat_res['py3']['status'], google_compat_res['py3']['status'], diff --git a/compatibility_server/pip_checker.py b/compatibility_server/pip_checker.py index e140e887..011bf3dd 100644 --- a/compatibility_server/pip_checker.py +++ b/compatibility_server/pip_checker.py @@ -313,7 +313,18 @@ def _run_command( error_msg="An error occurred while running the command {} in" "container. Error message: {}".format(command, e)) - if returncode and raise_on_failure: + # Checking for cases where the command was killed by a signal. + # If a process was killed by a signal, then it's exit code will be + # 128 + . + # If a docker container exits with a running command then it will be + # killed with SIGKILL => 128 + 9 = 137 + if returncode > 128 and returncode <= 137: + raise PipCheckerError( + error_msg="The command {} was killed by signal {}. " + "This likely means that the Docker container timed " + "out. Error msg: {}".format( + command, returncode - 128, output)) + elif returncode and raise_on_failure: raise PipError(error_msg=output, command=command, returncode=returncode) @@ -350,6 +361,7 @@ def _install(self, container: docker.models.containers.Container): stderr=True, raise_on_failure=False) if returncode: + # Checking for environment error environment_error = PIP_ENVIRONMENT_ERROR_PATTERN.search(output) if environment_error: raise PipError(error_msg=environment_error.group('error'), diff --git a/compatibility_server/test_pip_checker.py b/compatibility_server/test_pip_checker.py index 39730263..b189026e 100644 --- a/compatibility_server/test_pip_checker.py +++ b/compatibility_server/test_pip_checker.py @@ -79,7 +79,6 @@ def run(self, return self def exec_run(self, cmd, stdout=True, stderr=True): - import docker from datetime import datetime _stdout = subprocess.PIPE if stdout else None @@ -95,8 +94,8 @@ def exec_run(self, cmd, stdout=True, stderr=True): duration = current_time - self.start_time if duration > pip_checker.TIME_OUT: - raise docker.errors.APIError(message="time out", - explanation="Request time out.") + result.returncode = 137 + output = b'' return result.returncode, output @@ -128,7 +127,8 @@ def test__run_command_timeout(self): TIME_OUT = 0.1 patch_timeout = mock.patch('pip_checker.TIME_OUT', TIME_OUT) - with patch_timeout, self.assertRaises(pip_checker.PipCheckerError): + with patch_timeout, self.assertRaisesRegex( + pip_checker.PipCheckerError, 'killed by signal 9'): container = checker._run_container(MockDockerClient()) checker._run_command( container, diff --git a/dashboard/dashboard_builder.py b/dashboard/dashboard_builder.py index 260cee39..3ec9e9f9 100644 --- a/dashboard/dashboard_builder.py +++ b/dashboard/dashboard_builder.py @@ -306,7 +306,7 @@ def get_result(self, 'self': False, } ) - if status_type is 'self-success': + if status_type == 'self-success': status_type = 'pairwise-success' result = {