How to upload a volume to an image which is in 'in-use' status

Solution In Progress - Updated -

Environment

  • Red Hat OpenStack Platform 10
  • Red Hat OpenStack Platform 11
  • Red Hat OpenStack Platform 16.2

Issue

  • Not able to upload a volume to an image as the volume is in in-use status
$ cinder upload-to-image ebe650f0-cbb5-4d9e-9728-5e9292292c71 test-vol-to-image
ERROR: Invalid volume: Volume ebe650f0-cbb5-4d9e-9728-5e9292292c71 status must be available (HTTP 400) (Request-ID: req-46770821-e0c8-4842-b32e-42a1c3a16145) 

For RHOSP16.2

$ openstack image create --container-format bare --disk-format qcow2 --volume 35d05087-c9ab-4d79-be94-472bdafca911 testvol-image
Invalid volume: Volume 35d05087-c9ab-4d79-be94-472bdafca911 status must be available (HTTP 400) (Request-ID: req-fbe4dd6c-d7f5-405f-82d7-2ceea5aa607e)
  • Cinder upload-to-image is not working even if --force flag is used
$ cinder upload-to-image --force true ebe650f0-cbb5-4d9e-9728-5e9292292c71 test-vol-to-image
ERROR: Invalid volume: Volume ebe650f0-cbb5-4d9e-9728-5e9292292c71 status must be available (HTTP 400) (Request-ID: req-aa04f04c-752a-4a45-8317-e6b9aac07445) 

For RHOSP16.2

$ openstack image create --force --container-format bare --disk-format qcow2 --volume 35d05087-c9ab-4d79-be94-472bdafca911 testvol-image
Invalid volume: Volume 35d05087-c9ab-4d79-be94-472bdafca911 status must be available (HTTP 400) (Request-ID: req-150f420b-49cb-45b1-b33e-2e0862d9daff)
  • Not able to upload cinder volume to image from horizon dashboard even if the Force option is ticked.

Resolution

  • To upload a cinder volume to an image which is in in-use status forcefully, one has to enable enable_force_upload parameter in cinder.conf file on all the controller nodes and has to restart cinder services on all the controller nodes:
$egrep -i enable_force_upload /etc/cinder/cinder.conf 
#enable_force_upload = false
enable_force_upload = true

For RHOSP16.2

# egrep -i enable_force_upload /var/lib/config-data/puppet-generated/cinder/etc/cinder/cinder.conf
#enable_force_upload = false
enable_force_upload = true
  • On an HA controller setup, restart the cinder services as below:

1) Run the following command from any one of the controller node:

# pcs resource restart openstack-cinder-volume

2) Run the following command from all the controller nodes:

# systemctl restart openstack-cinder-api
# systemctl restart openstack-cinder-scheduler

For RHOSP16.2

# systemctl restart tripleo_cinder_api
# systemctl restart tripleo_cinder_scheduler
  • On a non HA setup, all the cinder services are managed by systemd and can be restarted using systemctl:
# systemctl restart openstack-cinder-volume
# systemctl restart openstack-cinder-api
# systemctl restart openstack-cinder-scheduler
  • After successfully restarting the services, the volume can be forcefully uploaded to image:
$ cinder upload-to-image --force True 8f29a413-3c7d-4a20-8bb5-5e4114f6a08a test-image

For RHOSP16.2

$ openstack image create --force --container-format bare --disk-format qcow2 --volume 35d05087-c9ab-4d79-be94-472bdafca911 testvol-image
  • Same can be achieved from the horizon dashboard ticking the Force checkbox.

  • An alternative way to upload the volume which is in in-use status is by creating a copy of the original volume and then uploading the copied volume to image:

$ cinder create --source-volid b420a623-d7ad-4dc3-9c85-9404dbc8866a --name copy-of-cirros-boot-vol 1

Root Cause

  • Uploading a volume to an image requires the volume to be in available state which is by design.

  • It prevents the creation of new image as the image may be corrupt if the volume it was uploaded from was in use.

  • Also note that there are some caveats of uploading a volume to image which is in in-use status:

1) The VM is not quiesced, some data might be in RAM and not synced to disk, so the status of the volume could be different than expected, leading to corrupt data
2) The volume might change during the upload, corrupting the data
3) The enable_force_upload option depends on the backend, so check with your storage vendor for availability.

Diagnostic Steps

  • Volume upload to image from CLI:
$ cinder upload-to-image ebe650f0-cbb5-4d9e-9728-5e9292292c71 test-vol-to-image
ERROR: Invalid volume: Volume ebe650f0-cbb5-4d9e-9728-5e9292292c71 status must be available (HTTP 400) (Request-ID: req-46770821-e0c8-4842-b32e-42a1c3a16145) 

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments