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

urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> #775

Open
freyes opened this issue May 31, 2022 · 1 comment · May be fixed by #777
Open

urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> #775

freyes opened this issue May 31, 2022 · 1 comment · May be fixed by #777
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@freyes
Copy link
Member

freyes commented May 31, 2022

Due to dns instability the download_image() could fail, it would be nice if it was wrapped with a retry decorator

https://github.com/openstack-charmers/zaza-openstack-tests/blob/master/zaza/openstack/utilities/openstack.py#L2290

# error codes that represent a dns issue
DNS_ISSUES = [...]

class DnsProblemError(Exception):
    pass

@retry(retry=retry_if_exception_type(DnsProblemError))
def download_image(image_url, target_file):
    ...
    try:
        urllib.request.urlretrieve(image_url, target_file)
    except urllib.error.URLError as ex:
        if type(ex.reason) == socket.gaierror and ex.reason.errno in DNS_ISSUES:
            raise DnsProblemError(ex)

Stacktrace seen in the CI

2022-05-21 12:10:00 [INFO] Downloading image bionic
2022-05-21 12:10:00 [INFO] Downloading http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img ...
2022-05-21 12:10:10 [ERROR] {'ceph': 'zaza-5c6d9259a4b4'}
2022-05-21 12:10:10 [ERROR] Model ceph (zaza-5c6d9259a4b4)
Traceback (most recent call last):
  File "/usr/lib/python3.8/urllib/request.py", line 1354, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 922, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 787, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/bin/functest-run-suite", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 364, in main
    func_test_runner(
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 277, in func_test_runner
    run_env_deployment(env_deployment, keep_model=preserve_model,
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 151, in run_env_deployment
    configure.configure(
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/charm_lifecycle/configure.py", line 51, in configure
    run_configure_list(functions)
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/charm_lifecycle/configure.py", line 37, in run_configure_list
    utils.get_class(func)()
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/openstack/charm_tests/glance/setup.py", line 164, in add_lts_image
    add_image(image_url,
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/openstack/charm_tests/glance/setup.py", line 100, in add_image
    openstack_utils.create_image(
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/openstack/utilities/openstack.py", line 2531, in create_image
    download_image(image_url, local_path)
  File "/home/ubuntu/src/review.opendev.org/openstack/charm-glance/.tox/func-target/lib/python3.8/site-packages/zaza/openstack/utilities/openstack.py", line 2253, in download_image
    urllib.request.urlretrieve(image_url, target_file)
  File "/usr/lib/python3.8/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1383, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.8/urllib/request.py", line 1357, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
@freyes freyes added enhancement New feature or request good first issue Good for newcomers labels May 31, 2022
@Regis-Caelum
Copy link

Hey @freyes, I can help.

@Regis-Caelum Regis-Caelum linked a pull request May 31, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants