Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.
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
2 changes: 1 addition & 1 deletion badge_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
14 changes: 13 additions & 1 deletion compatibility_server/pip_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + <signal number>.
# 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)
Expand Down Expand Up @@ -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'),
Expand Down
8 changes: 4 additions & 4 deletions compatibility_server/test_pip_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't mocking the docker container timeout behavior correctly before, which should actually return a 137 code instead of raising a docker.errors.APIError. Changing this to match the behavior and the test in line 123 is for testing the timeout error.

result.returncode = 137
output = b''

return result.returncode, output

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/dashboard_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def get_result(self,
'self': False,
}
)
if status_type is 'self-success':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

if status_type == 'self-success':
status_type = 'pairwise-success'

result = {
Expand Down