Currently all image size checks are made against the root disk size in the flavor, which is then treated as the absolute size of the root disk to create, overriding the min_disk value of the image and the image size itself. However when working with a range of images (for example a mix of Windows and Linux) it would be better to be able to use a single set of flavours whilst still honouring the min_disk value of the image. This would allow, for example, more efficient snapshots for images that do not need the full size of root_gb.
There are in effect two sets of values here that we want to bring clarity to:
The Image Creator can set:
- min_disk in image metadata to be the size root disk of the resulting instance. Can be set to 0 if they want to use the maximum size supported by the cloud provider
- image_size (in the way the image is created). If min_disk=0 this determines the size of the root disk, otherwise it must be less than min_disk
The Cloud Provider can set (via flavours)
- root_gb: The maximum size for a root disk (or 0 if they don’t care). This provides an upper bound to the size of a root disk and protects against snapshot sizes and images which re larger that the declared min_disk
- ephemeral_gb: How much additional disc space will allocate to the instance
The resulting logic will be:
- In the API the min_disk is not 0 it is checked to be <= root_gb, or <=ephemeral_gb if root_gb = 0 (i.e must fit into the storage defined by the flavor)
- In the compute manager, the size of the downloaded image is checked to be <= size of root_gb, or <= ephemeral_gb if root_gb = 0
- The size of the root disk will be:
min_disk=0 min_disk ≠ 0 root_gb = 0 image_size min_disk root_gb ≠0 root_gb min_disk
- The ephemeral disk is created to be (root_gb + ephemeral_gb) – size_of_root_disk
In this way root_gb and ephemeral_gb together define the amount of disk to be allocated to an instance, but images do not have to expand to full size of root_gb of the instance_type. Equally the cloud provide can define an upper bound on size of a root disc.