Add validation for galera_common grow.
Currently, galera_common cluster-create do the validation before call _create_instances. But cluster-grow does not validate it. Add validation could avoid some risks: 1.Flavor ID, nics NotFound exception. `Instance.create` also check this, but do this thing before `Instance.create` is better. 2.Flavor, volume, nics of all intances NotEqual exception. 3.Quotas exteed exception. Although `Instance.create` check quotas for single instance, we should check_quotas for all instances as a unit. Since there already has a method `_validate_cluster_instances`. Reuse the method could reduce code redundancy, but the method is not so "common", unlike cluster-create, there is no num_instances limits for cluster-grow. So, this patch move "check number of instances" code to method `create`. Change-Id: If25c3e66fc6f4ac83e434880d3f3fe66cb1d4fff
This commit is contained in:
parent
ccb6752f69
commit
5bc2231325
|
@ -60,11 +60,6 @@ class GaleraCommonCluster(cluster_models.Cluster):
|
|||
ds_conf = CONF.get(datastore_version.manager)
|
||||
num_instances = len(instances)
|
||||
|
||||
# Check number of instances is at least min_cluster_member_count
|
||||
if num_instances < ds_conf.min_cluster_member_count:
|
||||
raise exception.ClusterNumInstancesNotLargeEnough(
|
||||
num_instances=ds_conf.min_cluster_member_count)
|
||||
|
||||
# Checking volumes and get delta for quota check
|
||||
cluster_models.validate_instance_flavors(
|
||||
context, instances, ds_conf.volume_support, ds_conf.device_path)
|
||||
|
@ -134,6 +129,11 @@ class GaleraCommonCluster(cluster_models.Cluster):
|
|||
def create(cls, context, name, datastore, datastore_version,
|
||||
instances, extended_properties, locality, configuration):
|
||||
LOG.debug("Initiating Galera cluster creation.")
|
||||
ds_conf = CONF.get(datastore_version.manager)
|
||||
# Check number of instances is at least min_cluster_member_count
|
||||
if len(instances) < ds_conf.min_cluster_member_count:
|
||||
raise exception.ClusterNumInstancesNotLargeEnough(
|
||||
num_instances=ds_conf.min_cluster_member_count)
|
||||
cls._validate_cluster_instances(context, instances, datastore,
|
||||
datastore_version)
|
||||
# Updating Cluster Task
|
||||
|
@ -163,6 +163,9 @@ class GaleraCommonCluster(cluster_models.Cluster):
|
|||
datastore = self.ds
|
||||
datastore_version = self.ds_version
|
||||
|
||||
self._validate_cluster_instances(context, instances, datastore,
|
||||
datastore_version)
|
||||
|
||||
db_info.update(task_status=ClusterTasks.GROWING_CLUSTER)
|
||||
try:
|
||||
locality = srv_grp.ServerGroup.convert_to_hint(self.server_group)
|
||||
|
|
Loading…
Reference in New Issue