Unity driver not working with requests version 2.24.0

Bug #1885526 reported by Ryan Liang
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
New
Undecided
Unassigned

Bug Description

The Unity driver reports: TypeError: wrap_socket() got an unexpected keyword argument '_context'

The related error log is:
Jun 28 06:39:16.009881 cdh2h1 cinder-volume[16610]: DEBUG storops.connection.client [None req-0cc89ded-ec29-43a6-b1b9-ab222ae53a86 None None] REQ URL: [GET] https://10.228.226.197:443/api/types/basicSystemInfo?compact=True&fields=attributes.description,attributes.displayValue,attributes.initialValue,attributes.name,attributes.type,description,documentation,name,type {{(pid=16753) log_request /usr/local/lib/python3.7/dist-packages/storops/connection/client.py:168}}
Jun 28 06:39:16.062352 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager [None req-0cc89ded-ec29-43a6-b1b9-ab222ae53a86 None None] Failed to initialize driver.: TypeError: wrap_socket() got an unexpected keyword argument '_context'
Jun 28 06:39:16.062352 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager Traceback (most recent call last):
Jun 28 06:39:16.062352 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/opt/stack/new/cinder/cinder/volume/manager.py", line 466, in _init_host
Jun 28 06:39:16.062352 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager self.driver.do_setup(ctxt)
Jun 28 06:39:16.062352 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/opt/stack/new/cinder/cinder/volume/drivers/dell_emc/unity/driver.py", line 113, in do_setup
Jun 28 06:39:16.062352 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager self.replication_manager.do_setup(self)

...... snip ......

Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/storops/connection/client.py", line 100, in request
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager files=files_opener, **options)
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 530, in request
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager resp = self.send(prep, **send_kwargs)
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 643, in send
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager r = adapter.send(request, **kwargs)
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 449, in send
Jun 28 06:39:16.064916 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager timeout=timeout
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 677, in urlopen
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager chunked=chunked,
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 381, in _make_request
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager self._validate_conn(conn)
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 976, in _validate_conn
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager conn.connect()
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 370, in connect
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager ssl_context=context,
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/urllib3/util/ssl_.py", line 390, in ssl_wrap_socket
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager return context.wrap_socket(sock)
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/eventlet/green/ssl.py", line 437, in wrap_socket
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager return GreenSSLSocket(sock, *a, _context=self, **kw)
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager File "/usr/local/lib/python3.7/dist-packages/eventlet/green/ssl.py", line 76, in __new__
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager *args, **kw
Jun 28 06:39:16.065803 cdh2h1 cinder-volume[16610]: ERROR cinder.volume.manager TypeError: wrap_socket() got an unexpected keyword argument '_context'

This issue is similar with Manila issue https://bugs.launchpad.net/manila/+bug/1833160, and both of them are caused by eventlet issue https://github.com/eventlet/eventlet/issues/526.

It works without eventlet monkey_patch:
sam@cdh2h1:~$ python3.7
Python 3.7.5 (default, Nov 7 2019, 10:50:52)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import storops
>>> u = storops.UnitySystem('xxxxxx', 'xxxxxx', 'xxxxxx')
>>> u.serial_number
...... snip ......
'xxx4022893'

But doesn't work under eventlet monkey_patch:
sam@cdh2h1:~$ python3.7
Python 3.7.5 (default, Nov 7 2019, 10:50:52)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
>>> eventlet.monkey_patch()
>>> import storops
>>> u = storops.UnitySystem('xxxxxx', 'xxxxxx', 'xxxxxx')
>>> u.serial_number
...... snip ......
  File "/usr/local/lib/python3.7/dist-packages/eventlet/green/ssl.py", line 437, in wrap_socket
    return GreenSSLSocket(sock, *a, _context=self, **kw)
  File "/usr/local/lib/python3.7/dist-packages/eventlet/green/ssl.py", line 76, in __new__
    *args, **kw
TypeError: wrap_socket() got an unexpected keyword argument '_context'
>>>

From the diff between requests 2.23.0 and 2.24.0, requests uses ssl instead of pyopenssl.
https://github.com/psf/requests/compare/v2.23.0...v2.24.0#diff-375a14e45cf81919afe573d3a1364c09R96-R110
This maybe cause this issue.

Revision history for this message
Ryan Liang (ryan-liang) wrote :

This issue not only affect the Unity driver, but any driver who uses requests to do https connection.

Revision history for this message
Jon Cui (czl389) wrote :

Hey, Ryan! I've tested your script in python 3.6.8, and it works fine.

Versions:
Python 3.6.8
eventlet 0.25.1
storops 1.2.5
requests 2.24.0

Revision history for this message
Ryan Liang (ryan-liang) wrote :

It seems working in python 3.6. I met this issue in Manila and went back to python3.6.

The ssl is packed and delivered in the python package.

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.