Пример #1
0
def run_native_mesos_scheduler_main(context):
    clear_mesos_tools_cache()
    context.main_schedulers = main([
        '--soa-dir', context.soa_dir,
        '--stay-alive-seconds', '10',
        '--periodic-interval', '1'
    ])
Пример #2
0
def start_paasta_native_framework(context, reconcile_backoff):
    clear_mesos_tools_cache()
    system_paasta_config = load_system_paasta_config()
    system_paasta_config['docker_registry'] = 'docker.io'  # so busybox runs.

    context.scheduler = PaastaScheduler(
        service_name=context.service,
        instance_name=context.instance,
        cluster=context.cluster,
        system_paasta_config=system_paasta_config,
        service_config=context.new_config,
        reconcile_backoff=int(reconcile_backoff),
    )

    context.driver = create_driver(
        service=context.service,
        instance=context.instance,
        scheduler=context.scheduler,
        system_paasta_config=system_paasta_config,
    )

    context.driver.start()

    if not hasattr(context, 'framework_ids'):
        context.framework_ids = []

    for _ in xrange(10):
        if context.scheduler.framework_id:
            context.framework_ids.append(context.scheduler.framework_id)
            break
        time.sleep(1)
    else:
        raise Exception("Expected scheduler to successfully register before timeout")
Пример #3
0
def start_paasta_native_framework(context, reconcile_backoff):
    clear_mesos_tools_cache()
    system_paasta_config = load_system_paasta_config()
    system_paasta_config['docker_registry'] = 'docker.io'  # so busybox runs.

    context.scheduler = PaastaScheduler(
        service_name=context.service,
        instance_name=context.instance,
        cluster=context.cluster,
        system_paasta_config=system_paasta_config,
        service_config=context.new_config,
        reconcile_backoff=int(reconcile_backoff),
    )

    context.driver = create_driver(
        service=context.service,
        instance=context.instance,
        scheduler=context.scheduler,
        system_paasta_config=system_paasta_config,
    )

    context.driver.start()

    if not hasattr(context, 'framework_ids'):
        context.framework_ids = []

    for _ in xrange(10):
        if context.scheduler.framework_id:
            context.framework_ids.append(context.scheduler.framework_id)
            break
        time.sleep(1)
    else:
        raise Exception(
            "Expected scheduler to successfully register before timeout")
Пример #4
0
def run_native_mesos_scheduler_main(context):
    clear_mesos_tools_cache()
    context.main_schedulers = main([
        '--soa-dir', context.soa_dir,
        '--stay-alive-seconds', '10',
        '--periodic-interval', '1'
    ])
Пример #5
0
def run_native_mesos_scheduler_main(context):
    clear_mesos_tools_cache()
    context.main_schedulers = main([
        "--soa-dir",
        context.soa_dir,
        "--stay-alive-seconds",
        "10",
        "--periodic-interval",
        "1",
    ])
Пример #6
0
def _clean_up_paasta_native_frameworks(context):
    clear_mesos_tools_cache()
    # context.etc_paasta signals that we actually have configured the mesos-cli.json; without this, we don't know where
    # to connect to clean up paasta native frameworks.
    if hasattr(context, 'etc_paasta'):
        for framework in mesos_tools.get_mesos_master().frameworks(active_only=True):
            if framework.name.startswith('paasta '):
                paasta_print("cleaning up framework %s" % framework.name)
                try:
                    mesos_tools.terminate_framework(framework.id)
                except requests.exceptions.HTTPError as e:
                    paasta_print("Got exception when terminating framework %s: %s" % (framework.id, e))
Пример #7
0
def _clean_up_paasta_native_frameworks(context):
    clear_mesos_tools_cache()
    # context.etc_paasta signals that we actually have configured the mesos-cli.json; without this, we don't know where
    # to connect to clean up paasta native frameworks.
    if hasattr(context, "etc_paasta"):
        for framework in a_sync.block(
                mesos_tools.get_mesos_master().frameworks, active_only=True):
            if framework.name.startswith(
                    "paasta_native ") or framework.name == getattr(
                        context, "framework_name", ""):
                print("cleaning up framework %s" % framework.name)
                try:
                    mesos_tools.terminate_framework(framework.id)
                except requests.exceptions.HTTPError as e:
                    print(
                        f"Got exception when terminating framework {framework.id}: {e}"
                    )
Пример #8
0
def start_paasta_native_framework(context, scheduler, reconcile_backoff,
                                  framework_name):
    clear_mesos_tools_cache()
    system_paasta_config = load_system_paasta_config()
    system_paasta_config.config_dict[
        'docker_registry'] = 'docker.io'  # so busybox runs.

    if scheduler == 'paasta_native':
        scheduler_class = NativeScheduler
    elif scheduler == 'adhoc':
        scheduler_class = AdhocScheduler
    else:
        raise Exception("unknown scheduler: %s" % scheduler)

    context.framework_name = framework_name
    context.scheduler = scheduler_class(
        service_name=context.service,
        instance_name=context.instance,
        cluster=context.cluster,
        staging_timeout=30,
        system_paasta_config=system_paasta_config,
        service_config=context.new_config,
        reconcile_backoff=int(reconcile_backoff),
    )

    context.driver = create_driver(
        framework_name=framework_name,
        scheduler=context.scheduler,
        system_paasta_config=system_paasta_config,
    )

    context.driver.start()

    if not hasattr(context, 'framework_ids'):
        context.framework_ids = []

    for _ in range(10):
        if context.scheduler.framework_id:
            context.framework_ids.append(context.scheduler.framework_id)
            break
        time.sleep(1)
    else:
        raise Exception(
            "Expected scheduler to successfully register before timeout")
Пример #9
0
def should_not_be_framework_with_name(context, name):
    clear_mesos_tools_cache()
    assert name not in [
        f.name for f in mesos_tools.get_all_frameworks(active_only=True)
    ]
Пример #10
0
def should_not_be_framework_with_name(context, name):
    clear_mesos_tools_cache()
    assert name not in [f.name for f in mesos_tools.get_all_frameworks(active_only=True)]
Пример #11
0
def should_be_framework_with_id(context, name):
    clear_mesos_tools_cache()
    assert name in [
        f.name
        for f in a_sync.block(mesos_tools.get_all_frameworks, active_only=True)
    ]
Пример #12
0
def run_native_mesos_scheduler_main(context):
    clear_mesos_tools_cache()
    context.main_schedulers = main(
        ["--soa-dir", context.soa_dir, "--stay-alive-seconds", "10", "--periodic-interval", "1"]
    )