juju/juju — pull request #1205 by wallyworld (2014-11-21 04:24:04+00:00)
Title: Add capability to cache lxc images used for starting lxc containers

LXC image blobs are now cached in the state server blob store.
These changes do 2 things:
1. Faster container initialisation on all machines since each time a new node is created, the container image needs to be fetched.
2. Better expiry/replacement of old images. Because image requests come through Juju, Juju can decide to fetch a more recent image if the currently cached one is deemed too old.

There's a few new moving parts to make this work:

1. Image storage facility in state/imagestorage
This writes the image blobs and metadata to state storage.

2. HTTP service used to GET image blobs in apiserver
This serves image blobs from the state blob store.

3. LXC container creation changes
The -T parameter is used to instruct lxc-create to fetch the image blob from the state server rather than https://cloud-images.com

When the lxc-create script asks the state server for an image blob, if it is not yet in the database, the state server will fetch it from https://cloud-images, cache it in the blob store, and hand it back to lxc-create. When stored in the state server, the metadata includes the time at which the image was cached.

A similar workflow is already used to handle tools tarballs.