Using below curl command, cinder service returns 500 error
1. If volume passed to the curl command is in 'in-use' state,
curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X POST http://10.69.4.136:8776/v2/7dc3c5bbd69c45e8a0345497e36377d5/volumes/4f5454f8-a1d0-4907-8175-1f06dd2d93f8/action -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: a1a655ea182345d29f4d9816a4e0eb04" -d '{"os-attach": {"instance_uuid": "95adc232-652a-4986-aa38-64f035fce409","mountpoint": "/dev/vdc","mode": "rw"}}'
Error log of c-api:
2015-04-24 01:50:05.150 ERROR cinder.api.middleware.fault [req-4235a6f9-dbe9-4e2a-8284-8f7bb7dc1978 0de8c6faec4d4b9b8250c7d26cf27dec 7dc3c5bbd69c45e8a0345497e36377d5] Caught error: Remote error: Remote error: InvalidVolume Invalid volume: volume is already attached
[u'Traceback (most recent call last):\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 142, in _dispatch_and_reply\n executor_callback))\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 186, in _dispatch\n executor_callback)\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 130, in _do_dispatch\n result = func(ctxt, **new_args)\n', u' File "/usr/local/lib/python2.7/dist-packages/osprofiler/profiler.py", line 105, in wrapper\n return f(*args, **kwargs)\n', u' File "/opt/stack/cinder/cinder/volume/manager.py", line 843, in attach_volume\n return do_attach()\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_concurrency/lockutils.py", line 445, in inner\n return f(*args, **kwargs)\n', u' File "/opt/stack/cinder/cinder/volume/manager.py", line 774, in do_attach\n raise exception.InvalidVolume(reason=msg)\n', u'InvalidVolume: Invalid volume: volume is already attached\n']. None
None.
2015-04-24 01:50:05.151 INFO cinder.api.middleware.fault [req-4235a6f9-dbe9-4e2a-8284-8f7bb7dc1978 0de8c6faec4d4b9b8250c7d26cf27dec 7dc3c5bbd69c45e8a0345497e36377d5] http://10.69.4.136:8776/v2/7dc3c5bbd69c45e8a0345497e36377d5/volumes/4f5454f8-a1d0-4907-8175-1f06dd2d93f8/action returned with HTTP 500
2015-04-24 01:50:05.152 INFO eventlet.wsgi.server [req-4235a6f9-dbe9-4e2a-8284-8f7bb7dc1978 0de8c6faec4d4b9b8250c7d26cf27dec 7dc3c5bbd69c45e8a0345497e36377d5] 10.69.4.136 - - [24/Apr/2015 01:50:05] "POST /v2/7dc3c5bbd69c45e8a0345497e36377d5/volumes/4f5454f8-a1d0-4907-8175-1f06dd2d93f8/action HTTP/1.1" 500 401 3.760313
2. If instance ID is not UUID
curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X POST http://10.69.4.136:8776/v2/7dc3c5bbd69c45e8a0345497e36377d5/volumes/4f5454f8-a1d0-4907-8175-1f06dd2d93f8/action -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: a1a655ea182345d29f4d9816a4e0eb04" -d '{"os-attach": {"instance_uuid": "95adc232-652a-4986-aa38-64f035fce40ih8","mountpoint": "/dev/vdc2","mode": "rw"}}'
Error log of c-api:
2015-04-24 02:21:37.049 ERROR cinder.api.middleware.fault [req-fc87840a-80ce-44ec-87d0-9798383cbc84 0de8c6faec4d4b9b8250c7d26cf27dec 7dc3c5bbd69c45e8a0345497e36377d5] Caught error: Remote error: Remote error: InvalidUUID Expected a uuid but received 95adc232-652a-4986-aa38-64f035fce40ih8.
[u'Traceback (most recent call last):\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 142, in _dispatch_and_reply\n executor_callback))\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 186, in _dispatch\n executor_callback)\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 130, in _do_dispatch\n result = func(ctxt, **new_args)\n', u' File "/usr/local/lib/python2.7/dist-packages/osprofiler/profiler.py", line 105, in wrapper\n return f(*args, **kwargs)\n', u' File "/opt/stack/cinder/cinder/volume/manager.py", line 843, in attach_volume\n return do_attach()\n', u' File "/usr/local/lib/python2.7/dist-packages/oslo_concurrency/lockutils.py", line 445, in inner\n return f(*args, **kwargs)\n', u' File "/opt/stack/cinder/cinder/volume/manager.py", line 805, in do_attach\n raise exception.InvalidUUID(uuid=instance_uuid)\n', u'InvalidUUID: Expected a uuid but received 95adc232-652a-4986-aa38-64f035fce40ih8.\n']. None
None.
2015-04-24 02:21:37.050 INFO cinder.api.middleware.fault [req-fc87840a-80ce-44ec-87d0-9798383cbc84 0de8c6faec4d4b9b8250c7d26cf27dec 7dc3c5bbd69c45e8a0345497e36377d5] http://10.69.4.136:8776/v2/7dc3c5bbd69c45e8a0345497e36377d5/volumes/4f5454f8-a1d0-4907-8175-1f06dd2d93f8/action returned with HTTP 500
2015-04-24 02:21:37.050 INFO eventlet.wsgi.server [req-fc87840a-80ce-44ec-87d0-9798383cbc84 0de8c6faec4d4b9b8250c7d26cf27dec 7dc3c5bbd69c45e8a0345497e36377d5] 10.69.4.136 - - [24/Apr/2015 02:21:37] "POST /v2/7dc3c5bbd69c45e8a0345497e36377d5/volumes/4f5454f8-a1d0-4907-8175-1f06dd2d93f8/action HTTP/1.1" 500 401 3.678798
In both above cases, 400 error should be returned to the end user.
Fix proposed to branch: master /review. openstack. org/178565
Review: https:/