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

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) 
  • 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) 
  • 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
  • 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-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-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
  • 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

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.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.