Comment 3 for bug 1482403

Revision history for this message
Corey Wright (coreywright) wrote :

Steps to recreate:
1. Create instance based on a flavor that includes swap on a Xen-based openstack installation.
2. See that in the database the instance has a BDM for swap at /dev/xvdb, but nothing for /dev/xvdc.
3. See that on the instance it has swap at /dev/xvdc, but nothing at /dev/xvdb.
4. Try to attach a volume at /dev/xvdb, but fail because the database has swap at /dev/xvdb.
5. Try to attach a volume at /dev/xvdc, but fail because the instance has swap at /dev/xvdc.

The above problem was introduced with http://git.openstack.org/cgit/openstack/nova/commit/?id=7f8128f87f5a2fa93c857295fb7e4163986eda25.

The below explanation is relative to a Nova Git commit as of today (and therefor won't changed).

A BDM for swap, based on the flavor, is created in nova/compute/api.py (pseudo call-stack: [1][2][3][4]), which is incorrectly (based on Xen and historical behavior) assigned to /dev/xvdb (pseudo call-stack: [5][6][7][8][9][10][11]), of which specifically get_next_device_name() insures that /dev/xvdc, the proper device name, will never be used [12].

[1] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/api.py#L775
[2] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/api.py#L829
[3] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/api.py#L750
[4] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/api.py#L761
[5] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/manager.py#L1663
[6] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/manager.py#L1705
[7] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/manager.py#L1642
[8] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/manager.py#L1650
[9] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/utils.py#L107
[10] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/utils.py#L120
[11] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/utils.py#L127
[12] https://github.com/openstack/nova/blob/bd3b5a62/nova/compute/utils.py#L173

The swap is actually created in nova/virt/xenapi/vmops.py (pseudo call-stack: [13][14][15]), again based on flavor, but with no regard for the previously created bdm for swap.

[13] https://github.com/openstack/nova/blob/bd3b5a62/nova/virt/xenapi/vmops.py#L678
[14] https://github.com/openstack/nova/blob/bd3b5a62/nova/virt/xenapi/vmops.py#L741
[15] https://github.com/openstack/nova/blob/bd3b5a62/nova/virt/xenapi/vmops.py#L89