Ejemplo n.º 1
0
def convergence_failed(tenant_id, group_id, reasons, timedout=False):
    """
    Handle convergence failure

    :param str tenant_id: Tenant ID
    :param str group_id: Group ID
    :param reasons: List of :obj:`ErrorReason` objects
    :param bool timedout: Has convergence failed due to reason timing out?

    :return: convergence execution status
    :rtype: :obj:`ConvergenceIterationStatus`
    """
    yield Effect(LoadAndUpdateGroupStatus(tenant_id, group_id,
                                          ScalingGroupStatus.ERROR))
    presented_reasons = sorted(present_reasons(reasons))
    if len(presented_reasons) == 0:
        presented_reasons = [u"Unknown error occurred"]
    elif timedout:
        presented_reasons = ["Timed out: {}".format(reason)
                             for reason in presented_reasons]
    yield cf_err(
        'group-status-error', status=ScalingGroupStatus.ERROR.name,
        reasons=presented_reasons)
    yield Effect(UpdateGroupErrorReasons(tenant_id, group_id,
                                         presented_reasons))
    yield do_return(ConvergenceIterationStatus.Stop())
Ejemplo n.º 2
0
 def test_cf_err(self):
     """
     `cf_err` returns Effect with `Log` intent with cloud_feed=True
     and isError=True
     """
     seq = [(Log('message', dict(isError=True, cloud_feed=True, a=2,
                                 b=3)), lambda _: 'logged')]
     self.assertEqual(perform_sequence(seq, cf_err('message', a=2, b=3)),
                      'logged')
Ejemplo n.º 3
0
 def test_cf_err(self):
     """
     `cf_err` returns Effect with `Log` intent with cloud_feed=True
     and isError=True
     """
     seq = [
         (Log('message', dict(isError=True, cloud_feed=True, a=2, b=3)),
             lambda _: 'logged')
     ]
     self.assertEqual(perform_sequence(seq, cf_err('message', a=2, b=3)),
                      'logged')
Ejemplo n.º 4
0
def convergence_failed(scaling_group, reasons):
    """
    Handle convergence failure
    """
    yield Effect(UpdateGroupStatus(scaling_group=scaling_group,
                                   status=ScalingGroupStatus.ERROR))
    presented_reasons = sorted(present_reasons(reasons))
    if len(presented_reasons) == 0:
        presented_reasons = [u"Unknown error occurred"]
    yield cf_err(
        'group-status-error', status=ScalingGroupStatus.ERROR.name,
        reasons=presented_reasons)
    yield Effect(UpdateGroupErrorReasons(scaling_group, presented_reasons))
    yield do_return(ConvergenceIterationStatus.Stop())
Ejemplo n.º 5
0
def convergence_failed(scaling_group, reasons, timedout=False):
    """
    Handle convergence failure
    """
    yield Effect(
        UpdateGroupStatus(scaling_group=scaling_group,
                          status=ScalingGroupStatus.ERROR))
    presented_reasons = sorted(present_reasons(reasons))
    if len(presented_reasons) == 0:
        presented_reasons = [u"Unknown error occurred"]
    elif timedout:
        presented_reasons = [
            "Timed out: {}".format(reason) for reason in presented_reasons
        ]
    yield cf_err('group-status-error',
                 status=ScalingGroupStatus.ERROR.name,
                 reasons=presented_reasons)
    yield Effect(UpdateGroupErrorReasons(scaling_group, presented_reasons))
    yield do_return(ConvergenceIterationStatus.Stop())