Image upload metadata verified after its added to backing store

Bug #981319 reported by Joshua Harlow
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Triaged
Wishlist
Unassigned

Bug Description

When adding an image to glance it seems like the upload process uploads to the backing store then the image metadata is verified. This seems backwards, since the image metadata seems like it should be verified before the upload to the backing store occurs (thus allowing it to fail early).

An example:

....
2012-04-14 01:50:36 15823 DEBUG [glance.api.v1.images] Uploading image data for image 59b6ff21-530a-4e05-a717-e33b6f960b6a to XYZ
....
2012-04-14 01:50:39 15823 DEBUG [glance.api.v1.images] Updating image 59b6ff21-530a-4e05-a717-e33b6f960b6a data. Checksum set to 08f1dcbbdccff97682727132d83f7efeda379a06, size set to 25165824
2012-04-14 01:50:39 15823 DEBUG [glance.registry] Updating image metadata for image 59b6ff21-530a-4e05-a717-e33b6f960b6a...
2012-04-14 01:50:39 15823 DEBUG [glance.registry] Updating image metadata for image 59b6ff21-530a-4e05-a717-e33b6f960b6a...
2012-04-14 01:50:39 15823 ERROR [glance.api.v1.images] Failed to activate image. Got error: Data supplied was not valid.
2012-04-14 01:50:39 15823 ERROR [glance.api.v1.images] Details: 400 Bad Request
2012-04-14 01:50:39 15823 ERROR [glance.api.v1.images]
2012-04-14 01:50:39 15823 ERROR [glance.api.v1.images] The server could not comply with the request since it is either malformed or otherwise incorrect.
2012-04-14 01:50:39 15823 ERROR [glance.api.v1.images]
2012-04-14 01:50:39 15823 ERROR [glance.api.v1.images] Failed to update image metadata. Got error: Data supplied was not valid. Details: Invalid disk format 'None' for image.
2012-04-14 01:50:39 15823 DEBUG [eventlet.wsgi.server] 127.0.0.1 - - [14/Apr/2012 01:50:39] "POST /v1/images HTTP/1.1" 400 559 2.882290

Shouldn't this fail before we spend time writing the data to a backing store instead of after?

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Looking at the code, here's what appears to happen:

1) image metadata is updated with what the user provides
2) image status set to saving
3) image data streamed to store
4) image status set to active

This failure occurs when the image is being set to active since that's when we require a valid combination of disk_format and container_format. At this point, your image data has been uploaded to the store and you should be able to do another PUT with a valid disk_format/container_format and status='active'. I agree this isn't ideal, but its better than activating an image before we have any actual data.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

With that in mind, how would you like to proceed?

Changed in glance:
status: New → Incomplete
Revision history for this message
Joshua Harlow (harlowja) wrote :

Is it possible to validate the meta-data before anything is uploaded at all? Instead of a set to saving, stream, then validate it would seem more sane to do validate, saving, stream, activate?

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Yeah, that does seem to make more sense... So to fix this bug we need to move the validation out of the db layer and into the public api.

Changed in glance:
status: Incomplete → Triaged
importance: Undecided → Wishlist
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.