Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax condition error handling to allow more time #1914

Merged
merged 1 commit into from
Jul 19, 2018
Merged
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
10 changes: 7 additions & 3 deletions datadog_checks_dev/datadog_checks/dev/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import time

from six import string_types
from six.moves.urllib.error import URLError
from six.moves.urllib.request import urlopen

from .errors import RetryError
Expand All @@ -30,7 +29,7 @@ def __call__(self):
last_endpoint = endpoint
try:
request = urlopen(endpoint, timeout=self.timeout)
except URLError as e:
except Exception as e:
last_error = str(e)
break
else:
Expand Down Expand Up @@ -78,9 +77,12 @@ def __init__(self, command, patterns, matches=1, stdout=True, stderr=True, attem

def __call__(self):
log_output = ''
exit_code = 0

for _ in range(self.attempts):
result = run_command(self.command, capture=True, check=True)
result = run_command(self.command, capture=True)
exit_code = result.code

if self.stdout and self.stderr:
log_output = result.stdout + result.stderr
elif self.stdout:
Expand All @@ -100,8 +102,10 @@ def __call__(self):
else:
raise RetryError(
'Command: {}\n'
'Exit code: {}\n'
'Captured Output: {}'.format(
self.command,
exit_code,
log_output
)
)
Expand Down