~simplestreams-dev/simplestreams/trunk

Viewing all changes in revision 436.

GlanceMirror: fix a couple of race-related problems

First, what can happen is that .sync() is interrupted for external reasons
(service restarts, network issues,...) after first image has been uploaded
to Glance when syncing multiple images. On re-run, the uploaded image is
considered "synced" already, but since simplestreams index is written out
only at the end of the sync, all the metadata is lost. We solve this by
adding "simplestreams_metadata" as one of the properties of image in
Glance where we put a JSON representation of all the metadata fields from
the original simplestreams index entry. We then load them in
load_products() if they are defined. This results in a slightly different
auto.sync.json entry: "endpoint" and "region" are on the product entry,
instead of on the disk1.img entry.

Secondly, if sync is indeed interrupted after one or several images are
completely uploaded (but not all of them), there's no index file at all,
so any attempt to make use of them with juju would fail, even though it
should be fully functional. We solve this by calling "insert_products()"
at the end of the insert_item(). This means that the index is regenerated
after every single image is uploaded.

Along the way, I slightly improve insert_item() tests from the pre-req
branch to add a test for minimal data required, rename the existing one
using real world data to test_insert_item_full, and re-use that data for a
test for a newly added call to insert_products().

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: