Failed to set image property. Invalid input for field/attribute simplestreams_metadata. Value: ... is too long (HTTP 400)

Bug #1988942 reported by Diko Parvanov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
In Progress
Low
Jorge Merlino

Bug Description

Seems cinder doesn't allow long names for metadata:

Failed to set image property: Invalid input for field/attribute simplestreams_metadata. Value: {"aliases": "20.04,default,f,focal,lts,ubuntu", "arch": "amd64", "ftype": "disk1.img", "label": "release", "md5": "8646f69a6814ed96e27de0a1be1120a4", "os": "ubuntu", "pubname": "ubuntu-focal-20.04-amd64-server-20201111", "release": "focal", "release_codename": "Focal Fossa", "release_title": "20.04 LTS", "sha256": "151e5e797dc0131c4a1a41b76dac34c551389be67e6b551ab18c36026c420e6a", "size": "546570752", "support_eol": "2025-04-23", "supported": "True", "version": "20.04"}. '{"aliases": "20.04,default,f,focal,lts,ubuntu", "arch": "amd64", "ftype": "disk1.img", "label": "release", "md5": "8646f69a6814ed96e27de0a1be1120a4", "os": "ubuntu", "pubname": "ubuntu-focal-20.04-amd64-server-20201111", "release": "focal", "release_codename": "Focal Fossa", "release_title": "20.04 LTS", "sha256": "151e5e797dc0131c4a1a41b76dac34c551389be67e6b551ab18c36026c420e6a", "size": "546570752", "support_eol": "2025-04-23", "supported": "True", "version": "20.04"}' is too long (HTTP 400) (Request-ID: req-5e6c7ce5-b5bc-445f-9b59-9946845e1a0b)
One or more of the set operations failed
Traceback (most recent call last):
  File "/home/stack/myansible/lib/python3.6/site-packages/cliff/app.py", line 401, in run_subcommand
    result = cmd.run(parsed_args)
  File "/home/stack/myansible/lib/python3.6/site-packages/osc_lib/command/command.py", line 39, in run
    return super(Command, self).run(parsed_args)
  File "/home/stack/myansible/lib/python3.6/site-packages/cliff/command.py", line 185, in run
    return_code = self.take_action(parsed_args) or 0
  File "/home/stack/myansible/lib/python3.6/site-packages/openstackclient/volume/v2/volume.py", line 719, in take_action
    raise exceptions.CommandError(_("One or more of the "
osc_lib.exceptions.CommandError: One or more of the set operations failed
clean_up SetVolume: One or more of the set operations failed
END return value: 1

Tags: metadata
Revision history for this message
Diko Parvanov (dparv) wrote :
Changed in cinder:
importance: Undecided → Wishlist
status: New → Incomplete
tags: added: metadata
Revision history for this message
Sofia Enriquez (lsofia-enriquez) wrote :

Dear Diko Parvanov,

From the logs, I can see that you are using the cinder client and the error looks like this:

RESP BODY: {"badRequest": {"code": 400, "message": "Invalid input for field/attribute simplestreams_metadata. Value: {\"aliases\": \"20.04,default,f,focal,lts,ubuntu\", \"arch\": \"amd64\", \"ftype\": \"disk1.img\", \"label\": \"release\", \"md5\": \"8646f69a6814ed96e27de0a1be1120a4\", \"os\": \"ubuntu\", \"pubname\": \"ubuntu-focal-20.04-amd64-server-20201111\", \"release\": \"focal\", \"release_codename\": \"Focal Fossa\", \"release_title\": \"20.04 LTS\", \"sha256\": \"151e5e797dc0131c4a1a41b76dac34c551389be67e6b551ab18c36026c420e6a\", \"size\": \"546570752\", \"support_eol\": \"2025-04-23\", \"supported\": \"True\", \"version\": \"20.04\"}. '{\"aliases\": \"20.04,default,f,focal,lts,ubuntu\", \"arch\": \"amd64\", \"ftype\": \"disk1.img\", \"label\": \"release\", \"md5\": \"8646f69a6814ed96e27de0a1be1120a4\", \"os\": \"ubuntu\", \"pubname\": \"ubuntu-focal-20.04-amd64-server-20201111\", \"release\": \"focal\", \"release_codename\": \"Focal Fossa\", \"release_title\": \"20.04 LTS\", \"sha256\": \"151e5e797dc0131c4a1a41b76dac34c551389be67e6b551ab18c36026c420e6a\", \"size\": \"546570752\", \"support_eol\": \"2025-04-23\", \"supported\": \"True\", \"version\": \"20.04\"}' is too long"}}
POST call to volumev3 for http://172.22.8.3:8776/v3/74833ea5ad9e4d1db569803774547fc7/volumes/82449828-aa1e-468c-bfe8-ed79514fd9f7/action used request id req-5e6c7ce5-b5bc-445f-9b59-9946845e1a0b
Failed to set image property: Invalid input for field/attribute simplestreams_metadata. Value: {"aliases": "20.04,default,f,focal,lts,ubuntu", "arch": "amd64", "ftype": "disk1.img", "label": "release", "md5": "8646f69a6814ed96e27de0a1be1120a4", "os": "ubuntu", "pubname": "ubuntu-focal-20.04-amd64-server-20201111", "release": "focal", "release_codename": "Focal Fossa", "release_title": "20.04 LTS", "sha256": "151e5e797dc0131c4a1a41b76dac34c551389be67e6b551ab18c36026c420e6a", "size": "546570752", "support_eol": "2025-04-23", "supported": "True", "version": "20.04"}. '{"aliases": "20.04,default,f,focal,lts,ubuntu", "arch": "amd64", "ftype": "disk1.img", "label": "release", "md5": "8646f69a6814ed96e27de0a1be1120a4", "os": "ubuntu", "pubname": "ubuntu-focal-20.04-amd64-server-20201111", "release": "focal", "release_codename": "Focal Fossa", "release_title": "20.04 LTS", "sha256": "151e5e797dc0131c4a1a41b76dac34c551389be67e6b551ab18c36026c420e6a", "size": "546570752", "support_eol": "2025-04-23", "supported": "True", "version": "20.04"}' is too long (HTTP 400) (Request-ID: req-5e6c7ce5-b5bc-445f-9b59-9946845e1a0b)

Would you mind sharing the next information with us so the cinder team can reproduce the problem:

- Would you mind sharing an input sample to reproduce this without simplestream and check if this is a cinder problem or a simplestream feature problem?
- Steps to reproduce this. What command are you using to update the metadata?
- Cinder Version

Best Regards
Sofia

Changed in cinder:
importance: Wishlist → Low
Revision history for this message
Paul Goins (vultaire) wrote :

I looked at sources a little, but I'm not a cinder expert, so anyone who reads this, please take this with a grain of salt.

It looks like this is likely hitting cinder/api/contrib/volume_image_metadata.py, VolumeImageMetadataController.create(). That function has a @validation.schema(volume_image_metadata.set_image_metadata) decorator, and, if I'm reading it right, it defines the schema for metadata essentially as:

{"metadata": {nested dict with keys as 1-255 character strings and values as 0-255 character strings}}

In other words, the metadata field can contain many key/value pairs, and it doesn't look like there is a hardcoded limit in the number of pairs, but each key and value have a max length of 255 characters.

This is based on looking at the cinder master branch.

Interestingly, the volume_glance_metadata table of the cinder DB defines the key as a varchar(255), but the value as a text field, so it seems the DB schema may be able to allow longer values in theory without modification - it's the API's validation schema which is rejecting this.

...Again, this is my interpretation as a non-expert.

Revision history for this message
Paul Goins (vultaire) wrote (last edit ):

@Sofia: I'm from the same team as Diko; I'll try to add some context here.

As far as I can tell, this is simply a matter of a metadata field, simplestreams_metadata, being longer than supported by the API in question.

We leverage simplestreams to automatically synchronize images from external repositories (e.g. http://cloud-images.ubuntu.com/releases/) into glance. Looking at it's code, it's simply using the create/upload/update methods of glanceclient.Client.images to create/update images in glance.

I see images created by simplestreams which clearly have this field exceeding 255 characters. And I see we can create instances or volumes with this image passed in via the --image field, and the instances/volumes are created without error, and the simplestreams_metadata field appears to be copied over without a problem.

Honestly, I'm not exactly sure what action is taking place in the log files uploaded by Diko that is triggering this, since the above does work fine.

However, if I run "openstack volume set --image-property simplestreams_metadata='<blob with over 255 characters>'" - even if I try to set the exact same property which is already set - I do get the same error. So, that seems inconsistent that we can create servers/volumes against an image with a larger field like this, but we can't set the property directly.

I've reproduced this issue using cinder-api version 2:14.2.1-0ubuntu1~cloud0 from the bionic-updates/stein/main pocket of the ubuntu cloud archive, but based upon looking at the sources in the master branch, I believe this bug still exists in the trunk.

Hope this helps.

Best Regards,
Paul Goins

Revision history for this message
Diko Parvanov (dparv) wrote :

moving back to new as Paul as stated how to reproduce this

Changed in cinder:
status: Incomplete → New
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/868485

Changed in cinder:
status: New → In Progress
Changed in cinder:
assignee: nobody → Jorge Merlino (jorge-merlino)
Revision history for this message
sean mooney (sean-k-mooney) wrote :

as i noted on the patch the limit comes form nova not glance.

nova dropped support for custom image properties in 2015

when we converted images to be modelled as oslo versioned objects in
https://github.com/openstack/nova/commit/40c2a4d6b05db879f976fc7eaf7a1a5aa93b270c

as part of the request spec object spec
https://specs.openstack.org/openstack/nova-specs/specs/mitaka/implemented/request-spec-object-mitaka.html

nova stores image properties in the isntance_system_metadata db table with a max value length of 255

https://github.com/openstack/nova/blob/9dceb735f6926c71a8c2e2c6ef8b5e0a1363041d/nova/db/main/models.py#L945-L946

volume metadata may exceed 255 but each image metadata value may not exceed 255

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.