Public bug reported: If a session object is not provided to the glance client, the HTTPClient defined in glanceclient.common.http will create a session object. This session object leaks open connections because it is not properly closed when the object is no longer needed. This leads to a ResourceWarning about an unclosed socket:
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 55912), raddr=('192.168.24.2', 13292)> Example code: $ cat g.py #!/usr/bin/python3 -Wd import glanceclient.common.http as h client = h.get_http_client(endpoint='https://192.168.24.2:13292', token='<my magical token>', cacert='/etc/pki/ca-trust/source/anchors/cm-local-ca.pem', insecure=False) print(client.get('/v2/images')) Results in: $ ./g.py /usr/lib64/python3.6/importlib/_bootstrap_external.py:426: ImportWarning: Not importing directory /usr/lib/python3.6/site-packages/repoze: missing __init__ _warnings.warn(msg.format(portions[0]), ImportWarning) /usr/lib64/python3.6/importlib/_bootstrap_external.py:426: ImportWarning: Not importing directory /usr/lib/python3.6/site-packages/paste: missing __init__ _warnings.warn(msg.format(portions[0]), ImportWarning) /usr/lib/python3.6/site-packages/pytz/__init__.py:499: ResourceWarning: unclosed file <_io.TextIOWrapper name='/usr/share/zoneinfo/zone.tab' mode='r' encoding='UTF-8'> for l in open(os.path.join(_tzinfo_dir, 'zone.tab')) /usr/lib/python3.6/site-packages/eventlet/patcher.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp (<Response [200]>, {'images': [{<image data>}], 'first': '/v2/images', 'schema': '/v2/schemas/images'}) sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 55912), raddr=('192.168.24.2', 13292)> This can be mitigated by adding a __del__ function to glanceclient.common.http.HTTPClient that closes the session. ** Affects: glance Importance: Undecided Status: New -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to Glance. https://bugs.launchpad.net/bugs/1838694 Title: glanceclient doesn't cleanup session it creates if one is not provided Status in Glance: New Bug description: If a session object is not provided to the glance client, the HTTPClient defined in glanceclient.common.http will create a session object. This session object leaks open connections because it is not properly closed when the object is no longer needed. This leads to a ResourceWarning about an unclosed socket: sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 55912), raddr=('192.168.24.2', 13292)> Example code: $ cat g.py #!/usr/bin/python3 -Wd import glanceclient.common.http as h client = h.get_http_client(endpoint='https://192.168.24.2:13292', token='<my magical token>', cacert='/etc/pki/ca-trust/source/anchors/cm-local-ca.pem', insecure=False) print(client.get('/v2/images')) Results in: $ ./g.py /usr/lib64/python3.6/importlib/_bootstrap_external.py:426: ImportWarning: Not importing directory /usr/lib/python3.6/site-packages/repoze: missing __init__ _warnings.warn(msg.format(portions[0]), ImportWarning) /usr/lib64/python3.6/importlib/_bootstrap_external.py:426: ImportWarning: Not importing directory /usr/lib/python3.6/site-packages/paste: missing __init__ _warnings.warn(msg.format(portions[0]), ImportWarning) /usr/lib/python3.6/site-packages/pytz/__init__.py:499: ResourceWarning: unclosed file <_io.TextIOWrapper name='/usr/share/zoneinfo/zone.tab' mode='r' encoding='UTF-8'> for l in open(os.path.join(_tzinfo_dir, 'zone.tab')) /usr/lib/python3.6/site-packages/eventlet/patcher.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp (<Response [200]>, {'images': [{<image data>}], 'first': '/v2/images', 'schema': '/v2/schemas/images'}) sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('192.168.24.2', 55912), raddr=('192.168.24.2', 13292)> This can be mitigated by adding a __del__ function to glanceclient.common.http.HTTPClient that closes the session. To manage notifications about this bug go to: https://bugs.launchpad.net/glance/+bug/1838694/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp