Openstack Queens – Cinder: Deleting volumes using Mysql

Sometimes things get so broken you just have to hack stuff out of the database because the API’s are in a stuck state.

Here is what I did to successfully remove the volume entries for some stuck volumes after a MySQL server crash.

Note, You’ll also need to adjust the quotas table too to decrement the number of volumes used by that users

set @id :="b9840e99-f9f6-4a80-9dcc-dc51898d9cb3"; 
update cinder.volumes set status="available",attach_status="detached" where id=@id;
update cinder.volume_attachment set attach_status="detached",detach_time="2018-04-22 09:16:33",deleted=1,deleted_at="2018-04-23 08:16:33",updated_at="2018-04-23 08:16:33" where volume_id=@id;

Another little trick is to manually set volumes into an error state if they get stuck in a “Creating” state

update cinder.volumes set status="error" where status="creating";

Errors running Glance[Liberty] on Centos 7

When trying to install\run glance on Centos 7 I came across the following error

ImportError: No module named oslo_policy

This was resolved by installing the python oslo_policy module by running

pip install oslo.policy

You may or not need to install pip(Python’s equivalent to Yum almost?)

yum install python-pip

 

Thats all wonderful but now i get this!

AttributeError: 'module' object has no attribute 'PY2'

Research suggests that it’s the python ‘six’ package that is out of date

pip install --upgrade six

Solved!

Cinder – Resize root volume

To resize the root volume of an instance can be tricky, this worked for me

Note some commands, particularly “cinder reset-state” returned a HTTP 403, i had to run those as admin

 

[root@vm-os-ks01 ~]# source admin.rc
[root@vm-os-ks01 ~]# cinder reset-state --state available b35e676a-7593-458d-b6f4-cc60e075cfd4
[root@vm-os-ks01 ~]# nova volume-list
+--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
| ID                                   | Status    | Display Name | Size | Volume Type | Attached to                          |
+--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
| e1072658-7399-4505-a563-a5b6ed062325 | in-use    |              | 10   | sata        | 11684d86-5e17-4760-a32b-26ed6c47f1c1 |
| b5ac679f-76ae-45aa-b6ae-c2d4d87a97d0 | in-use    |              | 10   | sata        | 65717578-a520-4c63-a3b4-63537bce2332 |
| c3c88bc1-a6b8-4bdc-b1b1-d399b0696be8 | in-use    |              | 10   | sata        | 815043a2-44fa-487e-9912-ecc015bf6a46 |
| bef780ff-ac9f-492d-9504-11062e30acdf | in-use    |              | 40   | sata        | 76d7a922-3b5e-4154-ab61-cfca7810369d |
| b35e676a-7593-458d-b6f4-cc60e075cfd4 | available |              | 40   | sata        | 933899fe-b218-4eff-b2b1-658ae8068350 |
+--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
[root@vm-os-ks01 ~]# cinder extend b35e676a-7593-458d-b6f4-cc60e075cfd4 80
[root@vm-os-ks01 ~]# nova volume-list
+--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
| ID                                   | Status    | Display Name | Size | Volume Type | Attached to                          |
+--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
| e1072658-7399-4505-a563-a5b6ed062325 | in-use    |              | 10   | sata        | 11684d86-5e17-4760-a32b-26ed6c47f1c1 |
| b5ac679f-76ae-45aa-b6ae-c2d4d87a97d0 | in-use    |              | 10   | sata        | 65717578-a520-4c63-a3b4-63537bce2332 |
| c3c88bc1-a6b8-4bdc-b1b1-d399b0696be8 | in-use    |              | 10   | sata        | 815043a2-44fa-487e-9912-ecc015bf6a46 |
| bef780ff-ac9f-492d-9504-11062e30acdf | in-use    |              | 40   | sata        | 76d7a922-3b5e-4154-ab61-cfca7810369d |
| b35e676a-7593-458d-b6f4-cc60e075cfd4 | available |              | 80   | sata        | 933899fe-b218-4eff-b2b1-658ae8068350 |
+--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
[root@vm-os-ks01 ~]# cinder reset-state --state in-use b35e676a-7593-458d-b6f4-cc60e075cfd4
[root@vm-os-ks01 ~]# nova volume-list
+--------------------------------------+--------+--------------+------+-------------+--------------------------------------+
| ID                                   | Status | Display Name | Size | Volume Type | Attached to                          |
+--------------------------------------+--------+--------------+------+-------------+--------------------------------------+
| e1072658-7399-4505-a563-a5b6ed062325 | in-use |              | 10   | sata        | 11684d86-5e17-4760-a32b-26ed6c47f1c1 |
| b5ac679f-76ae-45aa-b6ae-c2d4d87a97d0 | in-use |              | 10   | sata        | 65717578-a520-4c63-a3b4-63537bce2332 |
| c3c88bc1-a6b8-4bdc-b1b1-d399b0696be8 | in-use |              | 10   | sata        | 815043a2-44fa-487e-9912-ecc015bf6a46 |
| bef780ff-ac9f-492d-9504-11062e30acdf | in-use |              | 40   | sata        | 76d7a922-3b5e-4154-ab61-cfca7810369d |
| b35e676a-7593-458d-b6f4-cc60e075cfd4 | in-use |              | 80   | sata        | 933899fe-b218-4eff-b2b1-658ae8068350 |
+--------------------------------------+--------+--------------+------+-------------+--------------------------------------+
[root@vm-os-ks01 ~]#