Esempio n. 1
0
def are_local_tasks_in_danger():
    try:
        system_paasta_config = utils.load_system_paasta_config()
        local_services = marathon_services_running_here()
        local_backends = get_backends(
            service=None,
            synapse_host=system_paasta_config.get_default_synapse_host(),
            synapse_port=system_paasta_config.get_synapse_port(),
            synapse_haproxy_url_format=system_paasta_config.
            get_synapse_haproxy_url_format(),
        )
        for service, instance, port in local_services:
            log.info(f"Inspecting {service}.{instance} on {port}")
            if is_healthy_in_haproxy(port, local_backends) and \
               synapse_replication_is_low(service, instance, system_paasta_config, local_backends=local_backends):
                log.warning(
                    "{}.{} on port {} is healthy but the service is in danger!"
                    .format(
                        service,
                        instance,
                        port,
                    ))
                return True
        return False
    except Exception:
        log.warning(traceback.format_exc())
        return False
Esempio n. 2
0
def should_be_discoverable_on_port(context, host_port):
    all_discovered = {}
    for slave_ip in socket.gethostbyname_ex('mesosslave')[2]:
        with mock.patch('paasta_tools.mesos_tools.socket.getfqdn',
                        return_value=slave_ip):
            discovered = marathon_tools.marathon_services_running_here()
            all_discovered[slave_ip] = discovered
            if discovered == [('bounce', 'test1', host_port)]:
                return

    raise Exception(
        "Did not find bounce.test1 in marathon_services_running_here for any of our slaves: %r",
        all_discovered)
def should_be_discoverable_on_port(context, host_port):
    all_discovered = {}
    for slave_ip in socket.gethostbyname_ex("mesosslave")[2]:
        with mock.patch(
            "paasta_tools.mesos_tools.socket.getfqdn",
            return_value=slave_ip,
            autospec=True,
        ):
            discovered = marathon_tools.marathon_services_running_here()
            all_discovered[slave_ip] = discovered
            if discovered == [("bounce", "test1", host_port)]:
                return

    raise Exception(
        "Did not find bounce.test1 in marathon_services_running_here for any of our slaves: %r",
        all_discovered,
    )
def get_all_services_running_here(cluster, soa_dir):
    try:
        marathon_services = marathon_services_running_here()
    except MesosSlaveConnectionError:
        marathon_services = []

    try:
        tron_services = tron_jobs_running_here()
    except MesosSlaveConnectionError:
        tron_services = []

    try:
        kubernetes_services = get_all_kubernetes_services_running_here()
    except Exception:
        kubernetes_services = []

    return marathon_services + tron_services + kubernetes_services
Esempio n. 5
0
def are_local_tasks_in_danger():
    try:
        system_paasta_config = utils.load_system_paasta_config()
        local_services = marathon_services_running_here()
        local_backends = get_backends(
            service=None,
            synapse_host=system_paasta_config.get_default_synapse_host(),
            synapse_port=system_paasta_config.get_synapse_port(),
            synapse_haproxy_url_format=system_paasta_config.get_synapse_haproxy_url_format()
        )
        for service, instance, port in local_services:
            log.info("Inspecting %s.%s on %s" % (service, instance, port))
            if is_healthy_in_haproxy(port, local_backends) and \
               synapse_replication_is_low(service, instance, system_paasta_config, local_backends=local_backends):
                log.warning("%s.%s on port %s is healthy but the service is in danger!" % (
                    service, instance, port
                ))
                return True
        return False
    except Exception:
        log.warning(traceback.format_exc())
        return False
Esempio n. 6
0
def _nerve_ports_for_service_instance(service_name, instance_name):
    """Return the nerve ports for a given service instance"""
    for name, instance, port in marathon_services_running_here():
        if name == service_name and instance_name == instance:
            yield port