Background: When a data disk is needed by a VM that resides in a different cluster (i.e. different primary storage) than the current cluster/primary storage, it involves a costly/time consuming data copy operation - which involved copying data from one primary storage to another primary storage via the secondary storage. A primary storage is not shared across multiple clusters. As an example, AWS EBS provides the following benefits: EBS volumes are placed in a specific Availability Zone, and can then be attached to any instance in that same Availability Zone. Even though a volume can only be attached to one instance at a time, if an instance fails or is detached from an EBS volume, the volume can be attached to any other instance in that Availability Zone.
Requirement: CloudStack to support zone-wide (primary) block storage
- Multiple clusters can share the same primary storage (as long as the underlying hypervisor platform supports it)
- Only one VM can mount/attach a disk at any time (i.e. multiple VMs cannot attach the same disk concurrently)
- snapshot/restore features are similar to current semantics i.e. no degradation in features
- we should allow multiple zone-wide primary storages
- only support for KVM with zone-wide primary storage in 4.1. Other hypervisors, like Xenserver and vmware, needs lot of extra work at the hypervisor level.
In the new storage framework, each storage can have its own life cycle, the storage will be not tied to a cluster or a host.
1. new column, called scope, will be added into storage_pool table. The scope has following attributes:
HOST, CLUSTER, ZONE;
Host means the storage is attached to a particular hypervisor host, a.k.a, it's the local storage.
Cluster, means the storage is attached to a cluster, it's the primary storage we have today.
Zone, means the storage is attached to a zone,
1. When adding a storage into cloudstack, admin needs to specify which scope he wants to add it into, either cluster or zone. Thus CreateStoragePoolCmd will have an extra parameter, called, scope.
If the scope is null, which means the scope is cluster, for api back-compatibility.
2. A new parameter, scope, will be added into ListStoragePoolsCmd, in order to list available storages in cloudstack.
If the scope is null, which means list storage pool whose scope attribute is cluster, for api back-compatibility.
1. CreateStoragePoolCmd with scope=zone
2. add storage pool into dabase
3. if there are kvm hosts in up state, send down a modifystoragepoolcmd to each kvm hosts in the zone
4. Then finished
5. Whenever a new kvm hosts added into the zone, also send down modifystoragepoolcmd to the host.
If there are zone-wide storages available in the zone, storage allocator will use the following algorithm:
1. Only use zone-wide storage, if it's for kvm hypervisor
2. If there are both cluster/host wide storages available for a kvm host, choose cluster or host wide storage at first.
3. If there is only zone-wide storages available for a kvm host, then choose one of storage, based on first-fit algorithm