Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

toaccess scripts crash on connection failure #5103

@ocket8888

Description

@ocket8888

I'm submitting a ...

  • bug report

Traffic Control components affected ...

  • Traffic Control Client (Python)

Current behavior:

When a connection-level error occurs, the scripts provided by the toaccess package crash, printing a stack trace to stderr.

Expected behavior:

When errors occur, scripts should print legibly what went wrong to stderr, then exit with an error code (it does exit properly with an exit code).

Minimal reproduction of the problem with instructions:

toget -fkp --to-url "http://notarealhost.test" ping

Anything else:

Stack trace
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 156, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.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 -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.8/http/client.py", line 1240, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1286, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1235, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1006, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 946, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 184, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 168, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f8d6b2b3b80>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
    return self.urlopen(
  [Previous line repeated 2 more times]
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='notarealhost.test', port=80): Max retries exceeded with url: /api/2.0/user/login (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8d6b2b3b80>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ocket8888/.local/bin/toget", line 8, in <module>
    sys.exit(get())
  File "/home/ocket8888/.local/lib/python3.8/site-packages/to_access/__init__.py", line 411, in get
    return request("get")
  File "/home/ocket8888/.local/lib/python3.8/site-packages/to_access/__init__.py", line 383, in request
    s, path, data, full, raw, pretty = parse_arguments("to%s" % method)
  File "/home/ocket8888/.local/lib/python3.8/site-packages/to_access/__init__.py", line 360, in parse_arguments
    s.login(to_user, to_passwd)
  File "/home/ocket8888/.local/lib/python3.8/site-packages/trafficops/tosession.py", line 160, in login
    self.post('user/login', data={'u': username, 'p': password})
  File "/home/ocket8888/.local/lib/python3.8/site-packages/trafficops/restapi.py", line 473, in post
    return self._do_operation(u'post', api_path, *args, **kwargs)
  File "/home/ocket8888/.local/lib/python3.8/site-packages/trafficops/restapi.py", line 404, in _do_operation
    response = getattr(self._session, operation)(endpoint, **params)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='notarealhost.test', port=80): Max retries exceeded with url: /api/2.0/user/login (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8d6b2b3b80>: Failed to establish a new connection: [Errno -2] Name or service not known'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    TC Client (python)related to the Python implementation of a TC clientbugsomething isn't working as intendedlow impactaffects only a small portion of a CDN, and cannot itself break one

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions