Volumes attached to shelved instance may contain incorrect device_name
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Won't Fix
|
High
|
Unassigned |
Bug Description
Nova supported to attach and detach volumes to/from shelved instances
since microversion 2.20.
When we attach a volume to an instance and
then unshelve the instance the cinder side doesn't include the
device_name information.
How to re-produce:
#1 shelve an instance
stack@SZX100028
---+---
| ID | Name | Status | Task State | Power State | Networks |
+------
| bd09421c-
+------
stack@SZX100028
stack@SZX100028
+------
| ID | Name | Status | Task State | Power State | Networks |
+------
| bd09421c-
+------
# 2 attach a cinder volume to the shelved insntace:
stack@SZX100028
+------
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+------
| a72f9642-
+------
stack@SZX100028
+------
| Property | Value |
+------
| device | - |
| id | a72f9642-
| serverId | bd09421c-
| volumeId | a72f9642-
+------
stack@SZX100028
+------
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+------
| a72f9642-
+------
stack@SZX100028
+------
| Property | Value |
+------
| Kevin network | 10.0.0.76, 172.24.4.10 |
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-
| OS-EXT-STS:vm_state | shelved_offloaded |
| OS-SRV-
| OS-SRV-
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2017-03-
| description | - |
| flavor | ds1G (d2) |
| hostId | |
| host_status | |
| id | bd09421c-
| image | CentOS (d826a98b-
| key_name | kevin_322 |
| locked | False |
| metadata | {} |
| name | test2 |
| os-extended-
| security_groups | default |
| status | SHELVED_OFFLOADED |
| tags | [] |
| tenant_id | 4f705543436648a
| updated | 2017-03-
| user_id | 46a372c04e38463
+------
#3 Unshelve the instance:
stack@SZX100028
stack@SZX100028
+------
| ID | Name | Status | Task State | Power State | Networks |
+------
| bd09421c-
+------
#4 Check details in cinder:
root@SZX1000280
+------
| Property | Value |
+------
| attachments | [{'server_id': 'bd09421c-
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2017-03-
| description | |
| encrypted | False |
| id | a72f9642-
| metadata | {'attached_mode': 'rw'} |
| migration_status | None |
| multiattach | False |
| name | test1 |
| os-vol-
| os-vol-
| os-vol-
| os-vol-
| replication_status | None |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | in-use |
| updated_at | 2017-03-
| user_id | 46a372c04e38463
| volume_type | lvmdriver-1 |
+------
After studied more, I discovered that this is because _attach_
This causes TWO problems,
1. nova volume-attach can be used with user provided device_name, in general case this name will be checked or ignored. In the shelved case, it will pass directly to Cinder thus Cinder will have wrong device_name [1], for example, I provide /dev/vda, when I do cinder show, it will show /dev/vda:
[1] http://
root@SZX1000280
+------
| Property | Value |
+------
| device | - |
| id | a72f9642-
| serverId | bd09421c-
| volumeId | a72f9642-
+------
root@SZX1000280
+------
| Property | Value |
+------
| attachments | [{'server_id': 'bd09421c-
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2017-03-
| description | |
| encrypted | False |
| id | a72f9642-
| metadata | {'attached_mode': 'rw'} |
| migration_status | None |
| multiattach | False |
| name | test1 |
| os-vol-
| os-vol-
| os-vol-
| os-vol-
| replication_status | None |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | in-use |
| updated_at | 2017-03-
| user_id | 46a372c04e38463
| volume_type | lvmdriver-1 |
+------
root@SZX1000280
+------
| ID | DEVICE | SERVER ID | VOLUME ID |
+------
| a72f9642-
+------
2. if user don't provide device_name, the Cinder side device_name will always be None.
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in nova: | |
assignee: | nobody → Zhenyu Zheng (zhengzhenyu) |
summary: |
- Volumes attached to shelved instance doesn't contain device_name + Volumes attached to shelved instance may contain incorrect device_name |
Changed in nova: | |
status: | New → In Progress |
Changed in nova: | |
importance: | Undecided → High |
This is mostly working as designed.
When attaching a volume to a shelved offloaded instance, there is no host for the instance so we can't call to the compute manager to reserve the device like we do for a normal attach here:
http:// git.openstack. org/cgit/ openstack/ nova/tree/ nova/compute/ api.py# n3687
So we create the BDM in the API and don't set a device name, because we can't say it's going to be the device name when we unshelve the instance:
http:// git.openstack. org/cgit/ openstack/ nova/tree/ nova/compute/ api.py# n3678
We've long talked about just removing the device_name option from the volume attach API because we can't guarantee that what the user requests is what's going to be in the guest, the hypervisor controls that, not nova. The libvirt driver completely ignores the user-requested device name.
So I think we want a spec to microversion the device_name field out of the volume attach request since it's just confusing and we can't honor it.
The thing we need to check is it the os-attach API in Cinder requires the mountpoint (which is the device name in the nova BDM).