Beispiel #1
0
def assert_chronos_scheduled_jobs(client):
    """
    :returns: a tuple of a string and a bool containing representing if it is ok or not
    """
    num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))
    return HealthCheckResult(message="Enabled chronos jobs: %d" % num_jobs,
                             healthy=True)
Beispiel #2
0
def assert_chronos_scheduled_jobs(client):
    """
    :returns: a tuple of a string and a bool containing representing if it is ok or not
    """
    try:
        num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))
    except ServerNotFoundError:
        num_jobs = 0
    return ("Enabled chronos jobs: %d" % num_jobs, True)
Beispiel #3
0
def assert_chronos_scheduled_jobs(client):
    """
    :returns: a tuple of a string and a bool containing representing if it is ok or not
    """
    try:
        num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))
    except ServerNotFoundError:
        num_jobs = 0
    return ("Enabled chronos jobs: %d" % num_jobs, True)
Beispiel #4
0
def assert_chronos_queued_jobs(client):
    high_priority_queue_size = client.metrics(
    )["gauges"][HIGH_QUEUE_GAUGE]["value"]
    normal_priority_queue_size = client.metrics(
    )["gauges"][QUEUE_GAUGE]["value"]
    all_jobs_queued = high_priority_queue_size + normal_priority_queue_size
    num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))

    try:
        perc_used = percent_used(num_jobs, all_jobs_queued)
    except ZeroDivisionError:
        perc_used = 0
    return HealthCheckResult(
        message=f"Jobs Queued: {all_jobs_queued} ({perc_used}%)", healthy=True)
Beispiel #5
0
def assert_chronos_queued_jobs(client):
    high_priority_queue_size = client.metrics()['gauges'][HIGH_QUEUE_GAUGE]['value']
    normal_priority_queue_size = client.metrics()['gauges'][QUEUE_GAUGE]['value']
    all_jobs_queued = high_priority_queue_size + normal_priority_queue_size
    num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))

    try:
        perc_used = percent_used(num_jobs, all_jobs_queued)
    except ZeroDivisionError:
        perc_used = 0
    return HealthCheckResult(
        message="Jobs Queued: %s (%s%%)" % (all_jobs_queued, perc_used),
        healthy=True
    )
Beispiel #6
0
def assert_chronos_queued_jobs(client):
    high_priority_queue_size = client.metrics()['gauges'][HIGH_QUEUE_GAUGE]['value']
    normal_priority_queue_size = client.metrics()['gauges'][QUEUE_GAUGE]['value']
    all_jobs_queued = high_priority_queue_size + normal_priority_queue_size
    num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))

    try:
        perc_used = percent_used(all_jobs_queued, num_jobs)
    except ZeroDivisionError:
        perc_used = 0
    return HealthCheckResult(
        message="Jobs Queued: %s (%s%%)" % (all_jobs_queued, perc_used),
        healthy=True
    )
def build_service_job_mapping(client, configured_jobs):
    """
    :param client: A Chronos client used for getting the list of running jobs
    :param configured_jobs: A list of jobs configured in Paasta, i.e. jobs we
    expect to be able to find
    :returns: A dict of {(service, instance): [(chronos job, lastrunstate)]}
    where the chronos job is any with a matching (service, instance) in its
    name and disabled == False
    """
    service_job_mapping = {}
    for job in configured_jobs:
        # find all the jobs belonging to each service
        matching_jobs = chronos_tools.lookup_chronos_jobs(
            service=job[0],
            instance=job[1],
            client=client,
        )
        # filter the enabled jobs
        enabled = chronos_tools.filter_enabled_jobs(matching_jobs)
        # get the last run state for the job
        with_states = last_run_state_for_jobs(enabled)
        service_job_mapping[job] = with_states
    return service_job_mapping
Beispiel #8
0
def build_service_job_mapping(client, configured_jobs):
    """
    :param client: A Chronos client used for getting the list of running jobs
    :param configured_jobs: A list of jobs configured in Paasta, i.e. jobs we
    expect to be able to find
    :returns: A dict of {(service, instance): [(chronos job, lastrunstate)]}
    where the chronos job is any with a matching (service, instance) in its
    name and disabled == False
    """
    service_job_mapping = {}
    for job in configured_jobs:
        # find all the jobs belonging to each service
        matching_jobs = chronos_tools.lookup_chronos_jobs(
            service=job[0],
            instance=job[1],
            client=client,
        )
        # filter the enabled jobs
        enabled = chronos_tools.filter_enabled_jobs(matching_jobs)
        # get the last run state for the job
        with_states = last_run_state_for_jobs(enabled)
        service_job_mapping[job] = with_states
    return service_job_mapping
Beispiel #9
0
def assert_chronos_scheduled_jobs(client):
    """
    :returns: a tuple of a string and a bool containing representing if it is ok or not
    """
    num_jobs = len(chronos_tools.filter_enabled_jobs(client.list()))
    return HealthCheckResult(message="Enabled chronos jobs: %d" % num_jobs, healthy=True)