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

Feature/3117 dbt deps timeout #3275

Merged
merged 10 commits into from
May 6, 2021
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
### Fixes
- Fix compiled sql for ephemeral models ([#3317](https:/fishtown-analytics/dbt/issues/3317), [#3318](https:/fishtown-analytics/dbt/pull/3318))

### Under the hood
- Added logic for registry requests to raise a timeout error after a response hangs out for 30 seconds and 5 attempts have been made to reach the endpoint ([#3117](https:/fishtown-analytics/dbt/issues/3177))

Contributors:
- [@TeddyCr](https:/TeddyCr) ([#3117](https:/fishtown-analytics/dbt/issues/3177))

## dbt 0.20.0b1 (May 03, 2021)

### Fixes
Expand Down
5 changes: 2 additions & 3 deletions core/dbt/clients/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ def wrapper(*args, **kwargs):
attempt += 1
try:
return fn(*args, **kwargs)
except requests.exceptions.ConnectionError as exc:
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as exc:
if attempt < max_attempts:
time.sleep(1)
continue

raise RegistryException(
'Unable to connect to registry hub'
) from exc
Expand All @@ -43,7 +42,7 @@ def wrapper(*args, **kwargs):
def _get(path, registry_base_url=None):
url = _get_url(path, registry_base_url)
logger.debug('Making package registry request: GET {}'.format(url))
resp = requests.get(url)
resp = requests.get(url, timeout=30)
logger.debug('Response from registry: GET {} {}'.format(url,
resp.status_code))
resp.raise_for_status()
Expand Down
9 changes: 9 additions & 0 deletions test/unit/test_registry_get_request_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import unittest

from dbt.exceptions import RegistryException
from dbt.clients.registry import _get

class testRegistryGetRequestException(unittest.TestCase):
def test_registry_request_error_catching(self):
# using non routable IP to test connection error logic in the _get function
self.assertRaises(RegistryException, _get, '', 'http://10.255.255.1')