Add support attach cinder volume to scale cluster
Partially implement blueprint attach-cinder-volume-scaling-support Change-Id: I54d23195c208ccd808d83c1d44a45014df5d3bae
This commit is contained in:
parent
46c95693b4
commit
ef4536ea98
@ -62,6 +62,7 @@ def scale_cluster(cluster, node_group_names_map):
|
||||
instances_list = _scale_cluster_instances(
|
||||
cluster, node_groups_map)
|
||||
_await_instances(cluster)
|
||||
volumes.attach_to_instances(instances_list)
|
||||
except Exception as ex:
|
||||
LOG.warn("Can't scale cluster: %s", ex)
|
||||
with excutils.save_and_reraise_exception():
|
||||
@ -261,7 +262,12 @@ def _rollback_cluster_creation(cluster, ex):
|
||||
|
||||
|
||||
def _rollback_cluster_scaling(instances):
|
||||
# if some nodes are up we should shut them down and update "count" in
|
||||
try:
|
||||
volumes.detach_from_instances(instances)
|
||||
except Exception:
|
||||
raise
|
||||
finally:
|
||||
#if some nodes are up we should shut them down and update "count" in
|
||||
# node_group
|
||||
ng_to_delete = []
|
||||
for i in instances:
|
||||
|
@ -30,6 +30,11 @@ def attach(cluster):
|
||||
_attach_volumes_to_node(node_group, instance)
|
||||
|
||||
|
||||
def attach_to_instances(instances):
|
||||
for instance in instances:
|
||||
_attach_volumes_to_node(instance.node_group, instance)
|
||||
|
||||
|
||||
def _await_attach_volume(instance, device_path):
|
||||
timeout = 10
|
||||
for _ in six.moves.xrange(timeout):
|
||||
@ -124,6 +129,15 @@ def _mount_volume(instance, device_path, mount_point):
|
||||
def detach(cluster):
|
||||
for node_group in cluster.node_groups:
|
||||
for instance in node_group.instances:
|
||||
_detach_volume_from_instance(instance)
|
||||
|
||||
|
||||
def detach_from_instances(instances):
|
||||
for instance in instances:
|
||||
_detach_volume_from_instance(instance)
|
||||
|
||||
|
||||
def _detach_volume_from_instance(instance):
|
||||
for volume_id in instance.volumes:
|
||||
volume = cinder.get_volume(volume_id)
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user