Error when attaching volume to instance

Bug #1492450 reported by Richard Hagarty
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
High
Richard Hagarty

Bug Description

After Nova patch https://review.openstack.org/#/c/219696 landed, Horizon users can no longer attach a volume to an instance.

The Nova API requires a non blank "device" value, or null. Horizon is passing a blank string, which results in the following exception:

Recoverable error: Invalid input for field/attribute device. Value: . u'' does not match '(^/dev/x{0,1}[a-z]{0,1}d{0,1})([a-z]+)[0-9]*$' (HTTP 400)

Revision history for this message
Ludwig Tirazona (ljtirazona-j) wrote :

This affects me as well, using a Horizon from a devstack deployment, with the following as the latest commit:

commit 2b566cbac7564de268cc27edebca558f1bda89d1
Merge: dee5c9d f9e0570
Author: Jenkins <email address hidden>
Date: Wed Sep 9 08:16:20 2015 +0000

    Merge "Fix typo in a document javacript => javascript"

Log from horizon.log:

2015-09-09 15:17:16.545322 REQ: curl -g -i 'http://<IPAddress>:8774/v2.1/4aa0fae8ea93417bbde856b26c413b51/servers/011fcb8e-9db3-4753-8136-01ee3174e452/os-volume_attachments' -X POST -H "Accept: application/json
" -H "Content-Type: application/json" -H "User-Agent: python-novaclient" -H "X-Auth-Project-Id: 4aa0fae8ea93417bbde856b26c413b51" -H "X-Auth-Token: {SHA1}bf37b4ec6147ee8a3e15415fadde16d406a6823e" -d '{"volumeAttac
hment": {"device": "", "volumeId": "b5d012b2-de59-440e-8823-8bf03d99e670"}}'
2015-09-09 15:17:16.559351 RESP: [400] {'content-length': '161', 'x-compute-request-id': 'req-3d5a6489-0c94-471f-aea1-ca4107e0b7ce', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'keep-alive', 'x-openstack
-nova-api-version': '2.1', 'date': 'Wed, 09 Sep 2015 15:17:16 GMT', 'content-type': 'application/json; charset=UTF-8'}
2015-09-09 15:17:16.559397 RESP BODY: null
2015-09-09 15:17:16.559402
2015-09-09 15:17:16.560191 Recoverable error: Invalid input for field/attribute device. Value: . u'' does not match '(^/dev/x{0,1}[a-z]{0,1}d{0,1})([a-z]+)[0-9]*$' (HTTP 400) (Request-ID: req-3d5a6489-0c94-471f-aea1-ca4107e0b7ce)
2015-09-09 15:17:17.124839 REQ: curl -g -i 'http://<IPAddress>:8774/v2.1/4aa0fae8ea93417bbde856b26c413b51/servers/detail?project_id=4aa0fae8ea93417bbde856b26c413b51' -X GET -H "Accept: application/json" -H "User-Agent: python-novaclient" -H "X-Auth-Project-Id: 4aa0fae8ea93417bbde856b26c413b51" -H "X-Auth-Token: {SHA1}bf37b4ec6147ee8a3e15415fadde16d406a6823e"
2015-09-09 15:17:17.208386 RESP: [200] {'content-length': '1702', 'x-compute-request-id': 'req-d0a12a3b-5360-4e81-a2c5-ba9d86326ca0', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'keep-alive', 'x-openstack-nova-api-version': '2.1', 'date': 'Wed, 09 Sep 2015 15:17:17 GMT', 'content-type': 'application/json'}

Revision history for this message
Ludwig Tirazona (ljtirazona-j) wrote :

Here's what I did to fix the problem:

Edited horizon/openstack_dashboard/api/nova.py

Line 751:
def instance_volume_attach(request, volume_id, instance_id, device):
    return novaclient(request).volumes.create_server_volume(instance_id,
                                                            volume_id,
                                                            device)
Changed to this:

def instance_volume_attach(request, volume_id, instance_id, device):
    return novaclient(request).volumes.create_server_volume(instance_id,
                                                            volume_id,
                                                            None)

To make sure that Horizon always passes a "None" value instead of a blank "".

Revision history for this message
Ludwig Tirazona (ljtirazona-j) wrote :

  Sorry, here's the actual patch.

Revision history for this message
Ludwig Tirazona (ljtirazona-j) wrote :

Sorry, here's the actual patch.

Changed in horizon:
assignee: nobody → Richard Hagarty (richard-hagarty)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/222390

Changed in horizon:
status: New → In Progress
David Lyle (david-lyle)
Changed in horizon:
importance: Undecided → High
milestone: none → liberty-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/222390
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=431f5605eb7d27b3067d459e8498b7150d6cc5f3
Submitter: Jenkins
Branch: master

commit 431f5605eb7d27b3067d459e8498b7150d6cc5f3
Author: Rich Hagarty <email address hidden>
Date: Thu Sep 10 15:24:13 2015 -0700

    Unable to attach volume to instance

    Nova api no longer allows blank device names when attaching
    a volume. In this case, the value needs to be set to None.

    Closes-Bug: #1492450
    Change-Id: Iae4d79ddd9c102782e27e0b641fb07167d3da63c

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: liberty-rc1 → 8.0.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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