コード例 #1
0
def uninstall(service_name, package_name=None):
    start = time.time()

    if package_name is None:
        package_name = service_name
    print('Uninstalling/janitoring {}'.format(service_name))
    try:
        shakedown.uninstall_package_and_wait(package_name,
                                             service_name=service_name)
    except (dcos.errors.DCOSException, ValueError) as e:
        print('Got exception when uninstalling package, ' +
              'continuing with janitor anyway: {}'.format(e))

    janitor_start = time.time()

    janitor_cmd = (
        'docker run mesosphere/janitor /janitor.py '
        '-r {svc}-role -p {svc}-principal -z dcos-service-{svc} --auth_token={auth}'
    )
    shakedown.run_command_on_master(
        janitor_cmd.format(svc=service_name,
                           auth=shakedown.run_dcos_command(
                               'config show core.dcos_acs_token')[0].strip()))

    finish = time.time()

    print('Uninstall done after pkg({}) + janitor({}) = total({})'.format(
        sdk_spin.pretty_time(janitor_start - start),
        sdk_spin.pretty_time(finish - janitor_start),
        sdk_spin.pretty_time(finish - start)))
コード例 #2
0
def uninstall(service_name, package_name=None):
    start = time.time()

    if package_name is None:
        package_name = service_name
    print('Uninstalling/janitoring {}'.format(service_name))
    try:
        shakedown.uninstall_package_and_wait(package_name, service_name=service_name)
    except (dcos.errors.DCOSException, ValueError) as e:
        print('Got exception when uninstalling package, ' +
              'continuing with janitor anyway: {}'.format(e))

    janitor_start = time.time()

    janitor_cmd = (
        'docker run mesosphere/janitor /janitor.py '
        '-r {svc}-role -p {svc}-principal -z dcos-service-{svc} --auth_token={auth}')
    shakedown.run_command_on_master(janitor_cmd.format(
        svc=service_name,
        auth=shakedown.run_dcos_command('config show core.dcos_acs_token')[0].strip()))

    finish = time.time()

    print('Uninstall done after pkg({}) + janitor({}) = total({})'.format(
        sdk_spin.pretty_time(janitor_start - start),
        sdk_spin.pretty_time(finish - janitor_start),
        sdk_spin.pretty_time(finish - start)))
コード例 #3
0
def teardown_module(module):
    # Remove everything from MoM
    with marathon_on_marathon():
        delete_all_apps_wait()
    # Uninstall MoM
    shakedown.uninstall_package_and_wait('marathon')
    # Remove everything from root marathon
    delete_all_apps_wait()
コード例 #4
0
    def fn():
        try:
            shakedown.uninstall_package_and_wait(PACKAGE_NAME)
        except (dcos.errors.DCOSException, json.decoder.JSONDecodeError):
            return False

        return shakedown.run_command_on_master(
            'docker run mesosphere/janitor /janitor.py '
            '-r cassandra-role -p cassandra-principal -z cassandra'
        )
コード例 #5
0
def teardown_module(module):
    with shakedown.marathon_on_marathon():
        try:
            clear_marathon()
        except:
            pass
    # Uninstall MoM
    shakedown.uninstall_package_and_wait('marathon')
    shakedown.delete_zk_node('universe/marathon-user')
    # Remove everything from root marathon
    clear_marathon()
コード例 #6
0
def package(request):
    package_name = request.param
    yield package_name
    try:
        shakedown.uninstall_package_and_wait(package_name)
        shakedown.delete_persistent_data(
            '{}-role'.format(package_name),
            'dcos-service-{}'.format(package_name))
    except Exception as e:
        # cleanup does NOT fail the test
        print(e)
コード例 #7
0
def package(request):
    package_name = request.param
    yield package_name
    try:
        shakedown.uninstall_package_and_wait(package_name)
        shakedown.delete_persistent_data(
            '{}-role'.format(package_name),
            'dcos-service-{}'.format(package_name))
    except Exception as e:
        # cleanup does NOT fail the test
        print(e)
コード例 #8
0
def teardown_module(module):
    with shakedown.marathon_on_marathon():
        try:
            clear_marathon()
        except:
            pass
    # Uninstall MoM
    shakedown.uninstall_package_and_wait('marathon')
    shakedown.delete_zk_node('universe/marathon-user')
    # Remove everything from root marathon
    clear_marathon()
コード例 #9
0
def uninstall():
    print("Uninstalling/janitoring {}".format(PACKAGE_NAME))
    try:
        shakedown.uninstall_package_and_wait(PACKAGE_NAME, service_name=PACKAGE_NAME)
    except (dcos.errors.DCOSException, ValueError) as e:
        print("Got exception when uninstalling package, continuing with janitor anyway: {}".format(e))

    shakedown.run_command_on_master(
        "docker run mesosphere/janitor /janitor.py "
        "-r cassandra-role -p {} -z dcos-service-cassandra "
        "--auth_token={}".format(PRINCIPAL, shakedown.run_dcos_command("config show core.dcos_acs_token")[0].strip())
    )
コード例 #10
0
def teardown_module(module):
    with shakedown.marathon_on_marathon():
        try:
            common.clean_up_marathon()
        except Exception:
            pass

    shakedown.uninstall_package_and_wait('marathon')
    shakedown.delete_zk_node('universe/marathon-user')

    # Remove everything from root marathon
    common.clean_up_marathon()
コード例 #11
0
def uninstall():
    print('Uninstalling/janitoring {}'.format(PACKAGE_NAME))
    try:
        shakedown.uninstall_package_and_wait(PACKAGE_NAME)
    except (dcos.errors.DCOSException, ValueError) as e:
        print(
            'Got exception when uninstalling package, continuing with janitor anyway: {}'
            .format(e))

    shakedown.run_command_on_master(
        "docker run mesosphere/janitor /janitor.py -r "
        "{}-role -p {}-principal -z dcos-service-{} --auth_token={}".format(
            PACKAGE_NAME, PACKAGE_NAME, PACKAGE_NAME, DCOS_TOKEN))
コード例 #12
0
def uninstall():
    print('Uninstalling/janitoring {}'.format(PACKAGE_NAME))
    try:
        shakedown.uninstall_package_and_wait(PACKAGE_NAME, app_id=PACKAGE_NAME)
    except (dcos.errors.DCOSException, ValueError) as e:
        print(
            'Got exception when uninstalling package, continuing with janitor anyway: {}'
            .format(e))

    shakedown.run_command_on_master(
        'docker run mesosphere/janitor /janitor.py '
        '-r kafka-role -p kafka-principal -z dcos-service-kafka '
        '--auth_token={}'.format(
            shakedown.run_dcos_command('config show core.dcos_acs_token')
            [0].strip()))
コード例 #13
0
def uninstall():
    print('Uninstalling/janitoring {}'.format(PACKAGE_NAME))
    try:
        shakedown.uninstall_package_and_wait(PACKAGE_NAME, app_id=PACKAGE_NAME)
    except (dcos.errors.DCOSException, ValueError) as e:
        print('Got exception when uninstalling package, continuing with janitor anyway: {}'.format(e))

    shakedown.run_command_on_master(
        'docker run mesosphere/janitor /janitor.py '
        '-r cassandra-role -p cassandra-principal -z dcos-service-cassandra '
        '--auth_token={}'.format(
            shakedown.run_dcos_command(
                'config show core.dcos_acs_token'
            )[0].strip()
        )
    )
コード例 #14
0
ファイル: command.py プロジェクト: shaurya10000/shakedown
def uninstall():
    print('Uninstalling/janitoring {}'.format(PACKAGE_NAME))
    traceback.print_stack()

    try:
        shakedown.uninstall_package_and_wait(PACKAGE_NAME,
                                             service_name=PACKAGE_NAME)
    except (dcos.errors.DCOSException, ValueError) as e:
        print(
            'Got exception when uninstalling package, continuing with janitor anyway: {}'
            .format(e))

    shakedown.run_command_on_master(
        'sudo docker run mesosphere/janitor /janitor.py '
        '-r {}-role -p {} -z dcos-service-{} '
        '--auth_token={}'.format(
            PACKAGE_NAME, PRINCIPAL, PACKAGE_NAME,
            shakedown.run_dcos_command('config show core.dcos_acs_token')
            [0].strip()))
コード例 #15
0
def uninstall():
    shakedown.uninstall_package_and_wait('chronos')
    shakedown.delete_zk_node('/chronos')
コード例 #16
0
def retried_uninstall_package_and_wait(*args, **kwargs):
    shakedown.uninstall_package_and_wait(*args, **kwargs)
コード例 #17
0
def teardown_module(module):
    shakedown.uninstall_package_and_wait(SPARK_PACKAGE_NAME)
コード例 #18
0
def _uninstall(
        package_name,
        service_name,
        role=None,
        service_account=None,
        zk=None):
    start = time.time()

    global _installed_service_names
    try:
        _installed_service_names.remove(service_name)
    except KeyError:
        pass # allow tests to 'uninstall' up-front

    if sdk_utils.dcos_version_less_than('1.10'):
        log.info('Uninstalling/janitoring {}'.format(service_name))
        try:
            shakedown.uninstall_package_and_wait(
                package_name, service_name=service_name)
        except (dcos.errors.DCOSException, ValueError) as e:
            log.info('Got exception when uninstalling package, ' +
                          'continuing with janitor anyway: {}'.format(e))
            if 'marathon' in str(e):
                log.info('Detected a probable marathon flake. Raising so retry will trigger.')
                raise

        janitor_start = time.time()

        # leading slash removed, other slashes converted to double underscores:
        deslashed_service_name = service_name.lstrip('/').replace('/', '__')
        if role is None:
            role = deslashed_service_name + '-role'
        if service_account is None:
            service_account = service_name + '-principal'
        if zk is None:
            zk = 'dcos-service-' + deslashed_service_name
        janitor_cmd = ('docker run mesosphere/janitor /janitor.py '
                       '-r {role} -p {service_account} -z {zk} --auth_token={auth}')
        shakedown.run_command_on_master(
            janitor_cmd.format(
                role=role,
                service_account=service_account,
                zk=zk,
                auth=sdk_cmd.run_cli('config show core.dcos_acs_token', print_output=False).strip()))

        finish = time.time()

        log.info(
            'Uninstall done after pkg({}) + janitor({}) = total({})'.format(
                shakedown.pretty_duration(janitor_start - start),
                shakedown.pretty_duration(finish - janitor_start),
                shakedown.pretty_duration(finish - start)))
    else:
        log.info('Uninstalling {}'.format(service_name))
        try:
            shakedown.uninstall_package_and_wait(
                package_name, service_name=service_name)
            # service_name may already contain a leading slash:
            marathon_app_id = '/' + service_name.lstrip('/')
            log.info('Waiting for no deployments for {}'.format(marathon_app_id))
            shakedown.deployment_wait(TIMEOUT_SECONDS, marathon_app_id)

            # wait for service to be gone according to marathon
            client = shakedown.marathon.create_client()
            def marathon_dropped_service():
                app_ids = [app['id'] for app in client.get_apps()]
                log.info('Marathon apps: {}'.format(app_ids))
                matching_app_ids = [
                    app_id for app_id in app_ids if app_id == marathon_app_id
                ]
                if len(matching_app_ids) > 1:
                    log.warning('Found multiple apps with id {}'.format(
                        marathon_app_id))
                return len(matching_app_ids) == 0
            log.info('Waiting for no {} Marathon app'.format(marathon_app_id))
            shakedown.time_wait(marathon_dropped_service, timeout_seconds=TIMEOUT_SECONDS)

        except (dcos.errors.DCOSException, ValueError) as e:
            log.info(
                'Got exception when uninstalling package: {}'.format(e))
            if 'marathon' in str(e):
                log.info('Detected a probable marathon flake. Raising so retry will trigger.')
                raise
        finally:
            sdk_utils.list_reserved_resources()
コード例 #19
0
ファイル: test.py プロジェクト: meua/spark-build
def teardown_module(module):
    shakedown.uninstall_package_and_wait('spark')
    if _hdfs_enabled():
        shakedown.uninstall_package_and_wait('hdfs')
        _run_janitor('hdfs')
コード例 #20
0
def teardown_module(module):
    shakedown.uninstall_package_and_wait(SPARK_PACKAGE_NAME)
    if utils.hdfs_enabled():
        shakedown.uninstall_package_and_wait(HDFS_PACKAGE_NAME, HDFS_SERVICE_NAME)
        _run_janitor(HDFS_SERVICE_NAME)
コード例 #21
0
def uninstall(service_name,
              package_name=None,
              role=None,
              principal=None,
              zk=None):
    start = time.time()

    if package_name is None:
        package_name = service_name

    if shakedown.dcos_version_less_than("1.10"):
        sdk_utils.out('Uninstalling/janitoring {}'.format(service_name))
        try:
            shakedown.uninstall_package_and_wait(package_name,
                                                 service_name=service_name)
        except (dcos.errors.DCOSException, ValueError) as e:
            sdk_utils.out('Got exception when uninstalling package, ' +
                          'continuing with janitor anyway: {}'.format(e))

        janitor_start = time.time()

        # leading slash removed, other slashes converted to double underscores:
        deslashed_service_name = service_name.lstrip('/').replace('/', '__')
        if role is None:
            role = deslashed_service_name + '-role'
        if principal is None:
            principal = service_name + '-principal'
        if zk is None:
            zk = 'dcos-service-' + deslashed_service_name
        janitor_cmd = ('docker run mesosphere/janitor /janitor.py '
                       '-r {role} -p {principal} -z {zk} --auth_token={auth}')
        shakedown.run_command_on_master(
            janitor_cmd.format(
                role=role,
                principal=principal,
                zk=zk,
                auth=shakedown.run_dcos_command(
                    'config show core.dcos_acs_token')[0].strip()))

        finish = time.time()

        sdk_utils.out(
            'Uninstall done after pkg({}) + janitor({}) = total({})'.format(
                shakedown.pretty_duration(janitor_start - start),
                shakedown.pretty_duration(finish - janitor_start),
                shakedown.pretty_duration(finish - start)))
    else:
        sdk_utils.out('Uninstalling {}'.format(service_name))
        try:
            shakedown.uninstall_package_and_wait(package_name,
                                                 service_name=service_name)
            # service_name may already contain a leading slash:
            marathon_app_id = '/' + service_name.lstrip('/')
            sdk_utils.out(
                'Waiting for no deployments for {}'.format(marathon_app_id))
            shakedown.deployment_wait(600, marathon_app_id)

            # wait for service to be gone according to marathon
            def marathon_dropped_service():
                client = shakedown.marathon.create_client()
                app_list = client.get_apps()
                app_ids = [app['id'] for app in app_list]
                sdk_utils.out('Marathon apps: {}'.format(app_ids))
                matching_app_ids = [
                    app_id for app_id in app_ids if app_id == marathon_app_id
                ]
                if len(matching_app_ids) > 1:
                    sdk_utils.out('Found multiple apps with id {}'.format(
                        marathon_app_id))
                return len(matching_app_ids) == 0

            sdk_utils.out(
                'Waiting for no {} Marathon app'.format(marathon_app_id))
            shakedown.time_wait(marathon_dropped_service)

        except (dcos.errors.DCOSException, ValueError) as e:
            sdk_utils.out(
                'Got exception when uninstalling package: {}'.format(e))
        finally:
            sdk_utils.list_reserved_resources()
コード例 #22
0
def teardown_spark():
    shakedown.uninstall_package_and_wait(SPARK_PACKAGE_NAME)
    _run_janitor()
コード例 #23
0
def retried_uninstall_package_and_wait(*args, **kwargs):
    shakedown.uninstall_package_and_wait(*args, **kwargs)
コード例 #24
0
ファイル: sdk_install.py プロジェクト: joerg84/dcos-commons
def _uninstall(
        package_name,
        service_name,
        role=None,
        service_account=None,
        zk=None):
    start = time.time()

    if shakedown.dcos_version_less_than("1.10"):
        log.info('Uninstalling/janitoring {}'.format(service_name))
        try:
            shakedown.uninstall_package_and_wait(
                package_name, service_name=service_name)
        except (dcos.errors.DCOSException, ValueError) as e:
            log.info('Got exception when uninstalling package, ' +
                          'continuing with janitor anyway: {}'.format(e))
            if 'marathon' in str(e):
                log.info('Detected a probable marathon flake. Raising so retry will trigger.')
                raise

        janitor_start = time.time()

        # leading slash removed, other slashes converted to double underscores:
        deslashed_service_name = service_name.lstrip('/').replace('/', '__')
        if role is None:
            role = deslashed_service_name + '-role'
        if service_account is None:
            service_account = service_name + '-principal'
        if zk is None:
            zk = 'dcos-service-' + deslashed_service_name
        janitor_cmd = ('docker run mesosphere/janitor /janitor.py '
                       '-r {role} -p {service_account} -z {zk} --auth_token={auth}')
        shakedown.run_command_on_master(
            janitor_cmd.format(
                role=role,
                service_account=service_account,
                zk=zk,
                auth=sdk_cmd.run_cli('config show core.dcos_acs_token', print_output=False).strip()))

        finish = time.time()

        log.info(
            'Uninstall done after pkg({}) + janitor({}) = total({})'.format(
                shakedown.pretty_duration(janitor_start - start),
                shakedown.pretty_duration(finish - janitor_start),
                shakedown.pretty_duration(finish - start)))
    else:
        log.info('Uninstalling {}'.format(service_name))
        try:
            shakedown.uninstall_package_and_wait(
                package_name, service_name=service_name)
            # service_name may already contain a leading slash:
            marathon_app_id = '/' + service_name.lstrip('/')
            log.info('Waiting for no deployments for {}'.format(marathon_app_id))
            shakedown.deployment_wait(TIMEOUT_SECONDS, marathon_app_id)

            # wait for service to be gone according to marathon
            def marathon_dropped_service():
                client = shakedown.marathon.create_client()
                app_list = client.get_apps()
                app_ids = [app['id'] for app in app_list]
                log.info('Marathon apps: {}'.format(app_ids))
                matching_app_ids = [
                    app_id for app_id in app_ids if app_id == marathon_app_id
                ]
                if len(matching_app_ids) > 1:
                    log.info('Found multiple apps with id {}'.format(
                        marathon_app_id))
                return len(matching_app_ids) == 0
            log.info('Waiting for no {} Marathon app'.format(marathon_app_id))
            shakedown.time_wait(marathon_dropped_service, timeout_seconds=TIMEOUT_SECONDS)

        except (dcos.errors.DCOSException, ValueError) as e:
            log.info(
                'Got exception when uninstalling package: {}'.format(e))
            if 'marathon' in str(e):
                log.info('Detected a probable marathon flake. Raising so retry will trigger.')
                raise
        finally:
            sdk_utils.list_reserved_resources()