Env: Glance is configured to use cinder as it's backend with multiple stores enabled.
When we upload a volume from cinder to glance, we face the following error and image never gets created.
glanceclient.exc.HTTPBadRequest: HTTP 400 Bad Request: Invalid location
This is because glance expected a location URI in the format
cinder://<store-id>/<vol-id>
instead cinder sends the URI
cinder://<vol-id>
Cinder cannot provide store-id since it doesn't have info about the glance stores and in which store the volume will be uploaded as an image.
Glance can handle this case by updating the location received from cinder (startswith("cinder://") and update it in the new format.
Steps to reproduce:
1. Configure glance to use Cinder store in multi store configuration
2. set the following cinder.conf options in the backend section
[<backend>]
image_upload_use_cinder_backend = True
image_upload_use_internal_tenant = True
3. Upload a volume to glance and check logs to verify the optimized path is taken
Here are the reference logs from a successful run
Create image volume (by cloning)
Jun 19 17:34:25 Ubuntu cinder-volume[835237]: DEBUG cinder.volume.manager [req-6c9ddac2-50ab-40aa-9ac2-612dce659101 req-1b038166-69c5-40ee-8312-3a589abd7e94 admin None] Creating image volume entry: {'volume_glance_metadata': [], 'consistencygroup_id': None, 'provider_id': None, 'group_id': None, 'previous_status': 'available', 'service_uuid': 'b11ecadf-5a67-4cb0-9988-b0b0b2584f8b', 'provider_auth': 'CHAP LW968dSz8Gj8cekHNQqz SsdYNRA5PbE3PWCy', 'updated_at': datetime.datetime(2024, 6, 19, 12, 4, 26, tzinfo=datetime.timezone.utc), 'ec2_id': None, 'project_id': 'b87315e82e6746858f53ecc804551571', 'replication_driver_data': None, 'provider_location': '127.0.0.1:3260;10.0.2.15:3260,iqn.2010-10.org.openstack:volume-78ee1687-fb5b-420e-9706-8944c5076033 iqn.2010-10.org.openstack:volume-78ee1687-fb5b-420e-9706-8944c5076033 0', 'host': 'Ubuntu@lvmdriver-1#lvmdriver-1', 'deleted': False, 'deleted_at': None, 'bootable': False, 'encryption_key_id': None, 'shared_targets': False, 'volume_admin_metadata': [], 'replication_extended_status': None, 'admin_metadata': {}, 'provider_geometry': None, 'metadata': {}, 'size': 1, 'volume_type_id': '57f1a15e-76e0-4e44-abb3-7e30c2c1f523', 'terminated_at': None, 'volume_metadata': [], 'scheduled_at': datetime.datetime(2024, 6, 17, 12, 51, 52, tzinfo=datetime.timezone.utc), 'availability_zone': 'nova', 'launched_at': datetime.datetime(2024, 6, 17, 12, 51, 53, tzinfo=datetime.timezone.utc), 'replication_status': None, 'cluster_name': None, 'multiattach': False, 'display_name': 'image-b73d7905-dab1-4503-962a-698ed384807a', 'display_description': None, 'created_at': datetime.datetime(2024, 6, 17, 12, 51, 52, tzinfo=datetime.timezone.utc), 'user_id': 'b9c61e5079de45e8b9cd1df9392c2827', 'attach_status': 'detached', 'status': 'creating', 'source_volid': '78ee1687-fb5b-420e-9706-8944c5076033'}. {{(pid=835237) _clone_image_volume /opt/stack/cinder/cinder/volume/manager.py:1680}}
Register location to glance
Jun 19 17:34:27 Ubuntu cinder-volume[835237]: DEBUG cinder.volume.manager [req-6c9ddac2-50ab-40aa-9ac2-612dce659101 req-1b038166-69c5-40ee-8312-3a589abd7e94 admin None] Registered image volume location to glance image-id: b73d7905-dab1-4503-962a-698ed384807a. {{(pid=835237) copy_volume_to_image /opt/stack/cinder/cinder/volume/manager.py:1806}}
Fix proposed to branch: master /review. opendev. org/c/openstack /glance/ +/922316
Review: https:/