Exemplo n.º 1
0
def _rollback_cluster_scaling(cluster, instances, ex):
    """Attempt to rollback cluster scaling."""
    LOG.info("Cluster '%s' scaling rollback (reason: %s)", cluster.name, ex)
    try:
        volumes.detach_from_instances(instances)
    finally:
        for i in instances:
            _shutdown_instance(i)
Exemplo n.º 2
0
def _rollback_cluster_scaling(cluster, instances, ex):
    """Attempt to rollback cluster scaling."""
    LOG.info("Cluster '%s' scaling rollback (reason: %s)", cluster.name, ex)
    try:
        volumes.detach_from_instances(instances)
    finally:
        for i in instances:
            _shutdown_instance(i)
Exemplo n.º 3
0
def _rollback_cluster_scaling(cluster, instances, ex):
    """Attempt to rollback cluster scaling."""
    LOG.info("Cluster '%s' scaling rollback (reason: %s)", cluster.name, ex)
    try:
        volumes.detach_from_instances(instances)
    except Exception:
        raise
    finally:
        for i in instances:
            ng = i.node_group
            _shutdown_instance(i)
            ng.count -= 1
Exemplo n.º 4
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete):
        instance = {'instance_id': '123454321', 'volumes': [123]}

        ng = r.NodeGroupResource({'instances': [instance]})

        p_get_volume.return_value = v.Volume(None, {'id': '123'})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(volumes.detach_from_instances([ng.instances[0]]))

        cluster = r.ClusterResource({'node_groups': [ng]})
        p_delete.side_effect = RuntimeError
        self.assertRaises(RuntimeError, volumes.detach, cluster)
Exemplo n.º 5
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete):
        instance = {'instance_id': '123454321',
                    'volumes': [123]}

        ng = r.NodeGroupResource({'instances': [instance]})

        p_get_volume.return_value = v.Volume(None, {'id': '123'})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(
            volumes.detach_from_instances([ng.instances[0]]))

        cluster = r.ClusterResource({'node_groups': [ng]})
        p_delete.side_effect = RuntimeError
        self.assertRaises(RuntimeError, volumes.detach, cluster)
Exemplo n.º 6
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete):
        instance = m.Instance(None, None, None)
        instance.volumes.append("123")

        p_get_volume.return_value = v.Volume(None, {'id': '123'})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(
            volumes.detach_from_instances([instance]))

        ng = m.NodeGroup(None, None, None, None)
        ng.instances.append(instance)
        cluster = m.Cluster(None, None, None, None)
        cluster.node_groups.append(ng)
        p_delete.side_effect = RuntimeError
        self.assertRaises(RuntimeError, volumes.detach, cluster)