python requests snap fails even in devmode

Bug #1707047 reported by fcole90
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

I created an app in python which uses the module requests. When I run it, it works correctly, but when I snap it, it fails with a ConnectionError.

I created a minimal snap app to reproduce the error.

The error is the following:
Traceback (most recent call last):
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/snap/requests-error/x1/usr/lib/python3.6/socket.py", line 743, 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 "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 357, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9b132a94a8>: 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 "/snap/requests-error/x1/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='google.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b132a94a8>: 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 "/snap/requests-error/x1/bin/requests-error.py", line 5, in <module>
    requests.get('http://google.com')
  File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/adapters.py", line 504, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='google.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b132a94a8>: Failed to establish a new connection: [Errno -2] Name or service not known',))

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: snapd 2.26.10+17.10
ProcVersionSignature: Ubuntu 4.11.0-10.15-generic 4.11.8
Uname: Linux 4.11.0-10-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia_drm nvidia_modeset nvidia
ApportVersion: 2.20.6-0ubuntu4
Architecture: amd64
CurrentDesktop: GNOME
Date: Thu Jul 27 20:48:13 2017
InstallationDate: Installed on 2015-03-21 (859 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha amd64 (20150321)
SourcePackage: snapd
UpgradeStatus: Upgraded to artful on 2017-07-18 (9 days ago)

Revision history for this message
fcole90 (fcole90) wrote :
Revision history for this message
Oliver Grawert (ogra) wrote :

you syslog might be helpful too (to see possible apparmor denials)

Revision history for this message
fcole90 (fcole90) wrote :

Here you are

Revision history for this message
fcole90 (fcole90) wrote :

grep "audit:" /var/log/syslog

Jul 31 08:25:22 fabio-X550JK kernel: [302910.244405] audit: type=1400 audit(1501482322.486:1258): apparmor="ALLOWED" operation="create" profile="snap.requests-error.requests-error" pid=12020 comm="python3" family="inet6" sock_type="stream" protocol=0 requested_mask="create" denied_mask="create"
Jul 31 08:25:22 fabio-X550JK kernel: [302910.244430] audit: type=1400 audit(1501482322.486:1259): apparmor="ALLOWED" operation="bind" profile="snap.requests-error.requests-error" pid=12020 comm="python3" family="inet6" sock_type="stream" protocol=6 requested_mask="bind" denied_mask="bind"
Jul 31 08:25:22 fabio-X550JK kernel: [302910.259839] audit: type=1400 audit(1501482322.502:1260): apparmor="ALLOWED" operation="open" profile="snap.requests-error.requests-error" name="/proc/12020/mounts" pid=12020 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473228] audit: type=1400 audit(1501482322.714:1261): apparmor="ALLOWED" operation="open" profile="snap.requests-error.requests-error" name="/etc/host.conf" pid=12020 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473240] audit: type=1400 audit(1501482322.714:1262): apparmor="ALLOWED" operation="open" profile="snap.requests-error.requests-error" name="/run/NetworkManager/resolv.conf" pid=12020 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473361] audit: type=1400 audit(1501482322.714:1263): apparmor="ALLOWED" operation="open" profile="snap.requests-error.requests-error" name="/etc/hosts" pid=12020 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473575] audit: type=1400 audit(1501482322.714:1264): apparmor="ALLOWED" operation="open" profile="snap.requests-error.requests-error" name="/run/NetworkManager/resolv.conf" pid=12020 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473576] audit: type=1400 audit(1501482322.714:1265): apparmor="ALLOWED" operation="create" profile="snap.requests-error.requests-error" pid=12020 comm="python3" family="inet" sock_type="dgram" protocol=0 requested_mask="create" denied_mask="create"
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473601] audit: type=1400 audit(1501482322.714:1266): apparmor="ALLOWED" operation="connect" profile="snap.requests-error.requests-error" pid=12020 comm="python3" family="inet" sock_type="dgram" protocol=17 requested_mask="connect" denied_mask="connect"
Jul 31 08:25:22 fabio-X550JK kernel: [302910.473614] audit: type=1400 audit(1501482322.714:1267): apparmor="ALLOWED" operation="sendmsg" profile="snap.requests-error.requests-error" pid=12020 comm="python3" laddr=127.0.0.1 lport=49998 faddr=127.0.1.1 fport=53 family="inet" sock_type="dgram" protocol=17 requested_mask="send" denied_mask="send"

Revision history for this message
fcole90 (fcole90) wrote :

Ogra, can you reproduce that or is it just a problem of mine?

Revision history for this message
John Lenton (chipaca) wrote :

Do you still have this problem, and if so, could you share the snap (or how to build it)? This way we might be able to reproduce the issue.

Changed in snapd (Ubuntu):
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for snapd (Ubuntu) because there has been no activity for 60 days.]

Changed in snapd (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.