Contents
This is a design document detailing the implementation of disks as a new top-level citizen in the config file (just like instances, nodes etc).
Currently, Disks are stored in Ganeti’s config file as a list (container) of Disk objects under the Instance in which they belong. This implementation imposes a number of limitations:
The implementation is going to be split in four parts:
The first patch-series is going to add a new top-level citizen in the config object (namely disks) and separate the disk objects from the instances. In doing so there are a number of problems that we have to overcome:
The Disk object gets two extra slots, _TIMESTAMPS and serial_no.
The Instance object will no longer contain the list of disk objects that are attached to it or a disk template. Instead, an Instance object will refer to its disks using their UUIDs and the disks will contain their own template. Since the order in which the disks are attached to an instance is important we are going to have a list of disk UUIDs under the Instance object which will denote the disks attached to the instance and their order at the same time. So the Instance’s disks slot is going to be a list of disk UUIDs. The Disk object is not going to have a slot pointing to the Instance in which it belongs since this is redundant.
A new function GetInstanceDisks will be added to the config that given an instance will return a list of Disk objects with the disks attached to this instance. This list will be exactly the same as ‘instance.disks’ was before. Everywhere in the code we are going to replace the ‘instance.disks’ (which from now one will contain a list of disk UUIDs) with the function GetInstanceDisks.
Since disks will not be part of the Instance object any more, ‘all_nodes’ and ‘secondary_nodes’ can not be Instance‘s properties. Instead we will use the functions GetInstanceNodes and GetInstanceSecondaryNodes from the config to compute these values.
The ConfigData object gets one extra slot: disks. Also there will be two new functions, AddDisk and RemoveDisk that will create/remove a disk objects from the config.
The VerifyConfig function will be changed so it can check that there are no dangling pointers from instances to disks (i.e. an instance points to a disk that doesn’t exist in the config).
The ‘upgrade’ operation for the config should check if disks are top level citizens and if not it has to extract the disk objects from the instances, replace them with their uuids, and copy the disk template. In case of the ‘downgrade’ operation (where disks will be made again part of the Instance object) all disks that are not attached to any instance at all will be ignored (removed from config). The disk template of the instance is set to the disk template of any disk attached to it. If there are multiple disk templates present, the downgrade fails and the user is requested to detach disks from the instances.
There are four operations that can be performed to a Disk object:
The first two operations will be performed using the config functions AddDisk and RemoveDisk respectively where the last two operations will be performed using the functions AttachInstanceDisk and DetachInstanceDisk.
Since Ganeti doesn’t allow for a Disk object to not be attached anywhere (for now) we will create two wrapper functions (namely AddInstanceDisk and RemoveInstanceDisk) which will add and attach a disk at the same time (respectively detach and remove a disk).
In addition since Ganeti doesn’t allow for a Disk object to be attached to more than one Instance at once, when attaching a disk to an instance we have to make sure that the disk is not attached anywhere else.
The backend needs access to the disks of an Instance but doesn’t have access to the GetInstanceDisks function from the config file. Thus we will create a new Instance slot (namely disks_info) that will get annotated (during RPC) with the instance’s disk objects. So in the backend we will only have to replace the disks slot with disks_info.
In order to remove the disk template from the instance model, all current uses of the disk template there need to be replaced. These uses fall into the following general categories: