Пример #1
0
def check_task(taskid, timeout=DEFAULT_TASK_TIMEOUT, wait=2):
    """Wrap check_task.

    Args:
        taskid (str): Existing Spinnaker Task ID.
        timeout (int, optional): Consider Task failed after given seconds.
        wait (int, optional): Seconds to pause between polling attempts.

    Returns:
        str: Task status.

    Raises:
        AssertionError: API did not respond with a 200 status code.
        :obj:`foremast.exceptions.SpinnakerTaskInconclusiveError`: Task did not
            reach a terminal state before the given time out.

    """
    max_attempts = int(timeout / wait)
    try:
        return retry_call(
            partial(_check_task, taskid),
            max_attempts=max_attempts,
            wait=wait,
            exceptions=(AssertionError, ValueError),
        )
    except ValueError:
        raise SpinnakerTaskInconclusiveError(
            'Task failed to complete in {0} seconds: {1}'.format(
                timeout, taskid))
Пример #2
0
def check_task(taskid, timeout=DEFAULT_TASK_TIMEOUT, wait=2):
    """Wrap check_task.

    Args:
        taskid (str): the task id returned from post_task
        timeout (int) (optional): how long to wait before failing the task
        wait (int, optional): Seconds to pause between polling attempts.

    Returns:
        polls for task status.

    Raises:
        AssertionError: API did not responde with a 200 status code.
        foremast.exceptions.SpinnakerTaskInconclusiveError: Task did not reach a
            terminal state in the given time.

    """
    max_attempts = int(timeout / wait)
    try:
        return retry_call(
            partial(_check_task, taskid),
            max_attempts=max_attempts,
            wait=wait,
            exceptions=(AssertionError, ValueError),
        )
    except ValueError:
        raise SpinnakerTaskInconclusiveError(
            'Task failed to complete in {0} seconds: {1}'.format(
                timeout, taskid))