コード例 #1
0
ファイル: local_run.py プロジェクト: ashwinaj/paasta
def paasta_local_run(args):
    if args.pull:
        build = False
    elif args.build:
        build = True
    else:
        build = local_makefile_present()

    service = figure_out_service_name(args, soa_dir=args.yelpsoa_config_root)
    base_docker_url = get_docker_host()
    docker_client = Client(base_url=base_docker_url)

    if build:
        default_tag = 'paasta-local-run-%s-%s' % (service, get_username())
        tag = os.environ.get('DOCKER_TAG', default_tag)
        os.environ['DOCKER_TAG'] = tag
        pull_image = False
        paasta_cook_image(None, service=service, soa_dir=args.yelpsoa_config_root)
    else:
        pull_image = True
        tag = None

    try:
        configure_and_run_docker_container(
            docker_client=docker_client,
            docker_hash=tag,
            service=service,
            args=args,
            pull_image=pull_image,
        )
    except errors.APIError as e:
        sys.stderr.write('Can\'t run Docker container. Error: %s\n' % str(e))
        sys.exit(1)
コード例 #2
0
ファイル: status.py プロジェクト: ashwinaj/paasta
def paasta_status(args):
    """Print the status of a Yelp service running on PaaSTA.
    :param args: argparse.Namespace obj created from sys.args by paasta_cli"""
    service = figure_out_service_name(args)
    actual_deployments = get_actual_deployments(service)
    deploy_info = get_deploy_info(service)
    if args.clusters is not None:
        cluster_whitelist = args.clusters.split(",")
    else:
        cluster_whitelist = []
    if args.instances is not None:
        instance_whitelist = args.instances.split(",")
    else:
        instance_whitelist = []

    if actual_deployments:
        deploy_pipeline = list(get_planned_deployments(deploy_info))
        report_status(
            service=service,
            deploy_pipeline=deploy_pipeline,
            actual_deployments=actual_deployments,
            cluster_whitelist=cluster_whitelist,
            instance_whitelist=instance_whitelist,
            verbose=args.verbose,
        )
    else:
        print missing_deployments_message(service)
コード例 #3
0
def paasta_status(args):
    """Print the status of a Yelp service running on PaaSTA.
    :param args: argparse.Namespace obj created from sys.args by paasta_cli"""
    service = figure_out_service_name(args)
    actual_deployments = get_actual_deployments(service)
    deploy_info = get_deploy_info(service)
    if args.clusters is not None:
        cluster_whitelist = args.clusters.split(",")
    else:
        cluster_whitelist = []
    if args.instances is not None:
        instance_whitelist = args.instances.split(",")
    else:
        instance_whitelist = []

    if actual_deployments:
        deploy_pipeline = list(get_planned_deployments(deploy_info))
        report_status(
            service=service,
            deploy_pipeline=deploy_pipeline,
            actual_deployments=actual_deployments,
            cluster_whitelist=cluster_whitelist,
            instance_whitelist=instance_whitelist,
            verbose=args.verbose,
        )
    else:
        print missing_deployments_message(service)
コード例 #4
0
ファイル: logs.py プロジェクト: nickrobinson/paasta
def paasta_logs(args):
    """Print the logs for as Paasta service.
    :param args: argparse.Namespace obj created from sys.args by paasta_cli"""
    service = figure_out_service_name(args)

    if args.clusters is None:
        clusters = list_clusters(service)
    else:
        clusters = args.clusters.split(",")

    if args.components is not None:
        components = args.components.split(",")
    else:
        components = DEFAULT_COMPONENTS

    if args.debug:
        log.setLevel(logging.DEBUG)
        levels = [DEFAULT_LOGLEVEL, 'debug']
    else:
        log.setLevel(logging.WARNING)
        levels = [DEFAULT_LOGLEVEL]

    log.info("Going to get logs for %s on clusters %s" % (service, clusters))
    if args.tail:
        tail_paasta_logs(service, levels, components, clusters, raw_mode=args.raw_mode)
    else:
        print "Non-tailing actions are not yet supported"
コード例 #5
0
ファイル: logs.py プロジェクト: georgekola/paasta
def paasta_logs(args):
    """Print the logs for as Paasta service.
    :param args: argparse.Namespace obj created from sys.args by paasta_cli"""
    service = figure_out_service_name(args)

    if args.clusters is None:
        clusters = list_clusters(service)
    else:
        clusters = args.clusters.split(",")

    if args.components is not None:
        components = args.components.split(",")
    else:
        components = DEFAULT_COMPONENTS

    if args.debug:
        log.setLevel(logging.DEBUG)
        levels = [DEFAULT_LOGLEVEL, 'debug']
    else:
        log.setLevel(logging.WARNING)
        levels = [DEFAULT_LOGLEVEL]

    log.info("Going to get logs for %s on clusters %s" % (service, clusters))
    if args.tail:
        tail_paasta_logs(service,
                         levels,
                         components,
                         clusters,
                         raw_mode=args.raw_mode)
    else:
        print "Non-tailing actions are not yet supported"
コード例 #6
0
ファイル: logs.py プロジェクト: titanous/paasta
def paasta_logs(args):
    """Print the logs for as Paasta service.
    :param args: argparse.Namespace obj created from sys.args by paasta_cli"""
    if 'scribereader' not in vars():
        sys.exit(
            "Unfortunately, `paasta logs` is unavailable without Scribe."
            " We're working to support alternative logging backends in PaaSTA:"
            " follow https://github.com/Yelp/paasta/issues/64 for updates."
        )
    service = figure_out_service_name(args)

    if args.clusters is None:
        clusters = list_clusters(service)
    else:
        clusters = args.clusters.split(",")

    if args.components is not None:
        components = args.components.split(",")
    else:
        components = DEFAULT_COMPONENTS

    if args.debug:
        log.setLevel(logging.DEBUG)
        levels = [DEFAULT_LOGLEVEL, 'debug']
    else:
        log.setLevel(logging.WARNING)
        levels = [DEFAULT_LOGLEVEL]

    log.info("Going to get logs for %s on clusters %s" % (service, clusters))
    if args.tail:
        tail_paasta_logs(service, levels, components, clusters, raw_mode=args.raw_mode)
    else:
        print "Non-tailing actions are not yet supported"
コード例 #7
0
ファイル: emergency_scale.py プロジェクト: ashwinaj/paasta
def paasta_emergency_scale(args):
    """Performs an emergency scale on a given service instance on a given cluster

    Warning: This command does not permanently scale the service. The next time the service is updated
    (config change, deploy, bounce, etc.), those settings will override the emergency scale.

    If you want this scale to be permanant, adjust the relevant config file to reflect that.
    For example, this can be done for Marathon apps by setting 'instances: n'
    """
    service = figure_out_service_name(args, soa_dir=args.yelpsoa_config_root)
    print "Performing an emergency scale on %s..." % compose_job_id(service, args.instance)
    output = execute_paasta_serviceinit_on_remote_master('scale', args.cluster, service, args.instance,
                                                         app_id=args.appid, delta=args.delta)
    print "Output: %s" % output
    print "%s" % "\n".join(paasta_emergency_scale.__doc__.splitlines()[-7:])
コード例 #8
0
def paasta_emergency_restart(args):
    """Performs an emergency restart on a given service instance on a given cluster

    Warning: This command is only intended to be used in an emergency.
    It should not be needed in normal circumstances.

    See the service-docs for paasta emergency-stop and emergency-start for details of what exactly this does:
    http://servicedocs.yelpcorp.com/docs/paasta_tools/generated/paasta_tools.paasta_cli.cmds.emergency_stop.html
    http://servicedocs.yelpcorp.com/docs/paasta_tools/generated/paasta_tools.paasta_cli.cmds.emergency_start.html
    """
    service = figure_out_service_name(args)
    print "Performing an emergency restart on %s...\n" % compose_job_id(service, args.instance)
    execute_paasta_serviceinit_on_remote_master('restart', args.cluster, service, args.instance)
    print "%s" % "\n".join(paasta_emergency_restart.__doc__.splitlines()[-7:])
    print "Run this to see the status:"
    print "paasta status --service %s --clusters %s" % (service, args.cluster)
コード例 #9
0
ファイル: emergency_restart.py プロジェクト: ashwinaj/paasta
def paasta_emergency_restart(args):
    """Performs an emergency restart on a given service instance on a given cluster

    Warning: This command is only intended to be used in an emergency.
    It should not be needed in normal circumstances.

    See the service-docs for paasta emergency-stop and emergency-start for details of what exactly this does:
    http://servicedocs.yelpcorp.com/docs/paasta_tools/generated/paasta_tools.paasta_cli.cmds.emergency_stop.html
    http://servicedocs.yelpcorp.com/docs/paasta_tools/generated/paasta_tools.paasta_cli.cmds.emergency_start.html
    """
    service = figure_out_service_name(args)
    print "Performing an emergency restart on %s...\n" % compose_job_id(service, args.instance)
    execute_paasta_serviceinit_on_remote_master("restart", args.cluster, service, args.instance)
    print "%s" % "\n".join(paasta_emergency_restart.__doc__.splitlines()[-7:])
    print "Run this to see the status:"
    print "paasta status --service %s --clusters %s" % (service, args.cluster)
コード例 #10
0
ファイル: emergency_start.py プロジェクト: ashwinaj/paasta
def paasta_emergency_start(args):
    """Performs an emergency start on a given service instance on a given cluster

    Warning: This command is not magic and cannot actually get a service to start if it couldn't
    run before. This includes configurations that prevent the service from running,
    such as 'instances: 0' (for Marathon apps).

    All it does for Marathon apps is ask Marathon to resume normal operation by scaling up to
    the instance count defined in the service's config.
    All it does for Chronos jobs is send the latest version of the job config to Chronos and run it immediately.
    """
    service = figure_out_service_name(args)
    print "Performing an emergency start on %s..." % compose_job_id(service, args.instance)
    execute_paasta_serviceinit_on_remote_master("start", args.cluster, service, args.instance)
    print "%s" % "\n".join(paasta_emergency_start.__doc__.splitlines()[-8:])
    print "Run this command to see the status:"
    print "paasta status --service %s --clusters %s" % (service, args.cluster)
コード例 #11
0
ファイル: emergency_start.py プロジェクト: georgekola/paasta
def paasta_emergency_start(args):
    """Performs an emergency start on a given service instance on a given cluster

    Warning: This command is not magic and cannot actually get a service to start if it couldn't
    run before. This includes configurations that prevent the service from running,
    such as 'instances: 0' (for Marathon apps).

    All it does for Marathon apps is ask Marathon to resume normal operation by scaling up to
    the instance count defined in the service's config.
    All it does for Chronos jobs is send the latest version of the job config to Chronos and run it immediately.
    """
    service = figure_out_service_name(args)
    print "Performing an emergency start on %s..." % compose_job_id(service, args.instance)
    execute_paasta_serviceinit_on_remote_master('start', args.cluster, service, args.instance)
    print "%s" % "\n".join(paasta_emergency_start.__doc__.splitlines()[-8:])
    print "Run this command to see the status:"
    print "paasta status --service %s --clusters %s" % (service, args.cluster)
コード例 #12
0
ファイル: emergency_stop.py プロジェクト: ashwinaj/paasta
def paasta_emergency_stop(args):
    """Performs an emergency stop on a given service instance on a given cluster

    Warning: This command does not permanently stop the service. The next time the service is updated
    (config change, deploy, bounce, etc.), those settings will override the emergency stop.

    If you want this stop to be permanant, adjust the relevant config file to reflect that.
    For example, this can be done for Marathon apps by setting 'instances: 0', or
    for Chronos jobs by setting 'disabled: True'. Alternatively, remove the config yaml entirely.
    """
    service = figure_out_service_name(args, soa_dir=args.yelpsoa_config_root)
    print "Performing an emergency stop on %s..." % compose_job_id(service, args.instance)
    output = execute_paasta_serviceinit_on_remote_master('stop', args.cluster, service, args.instance,
                                                         app_id=args.appid)
    print "Output: %s" % output
    print "%s" % "\n".join(paasta_emergency_stop.__doc__.splitlines()[-7:])
    print "To start this service again asap, run:"
    print "paasta emergency-start --service %s --instance %s --cluster %s" % (service, args.instance, args.cluster)
コード例 #13
0
def paasta_start_or_stop(args, desired_state):
    """Requests a change of state to start or stop given branches of a service."""
    service = figure_out_service_name(args)
    instance = args.instance
    cluster = args.cluster

    branch = "paasta-%s.%s" % (cluster, instance)
    all_branches = list(get_branches(service))

    if branch not in all_branches:
        print "No branches found for %s in %s." % \
            (branch, all_branches)
        print "Has it been deployed there yet?"
        sys.exit(1)

    force_bounce = format_timestamp(datetime.datetime.utcnow())
    branches = [branch]
    issue_state_change_for_branches(service, instance, cluster, branches,
                                    force_bounce, desired_state)
コード例 #14
0
ファイル: start_stop_restart.py プロジェクト: ashwinaj/paasta
def paasta_start_or_stop(args, desired_state):
    """Requests a change of state to start or stop given branches of a service."""
    service = figure_out_service_name(args)
    instance = args.instance
    cluster = args.cluster

    branch = "paasta-%s.%s" % (cluster, instance)
    all_branches = list(get_branches(service))

    if branch not in all_branches:
        print "No branches found for %s in %s." % \
            (branch, all_branches)
        print "Has it been deployed there yet?"
        sys.exit(1)

    force_bounce = format_timestamp(datetime.datetime.utcnow())
    branches = [branch]
    issue_state_change_for_branches(service, instance, cluster, branches, force_bounce,
                                    desired_state)
コード例 #15
0
ファイル: local_run.py プロジェクト: nickrobinson/paasta
def paasta_local_run(args):
    validate_environment()

    service = figure_out_service_name(args, soa_dir=args.yelpsoa_config_root)

    base_docker_url = get_docker_host()

    docker_client = Client(base_url=base_docker_url)

    default_tag = 'paasta-local-run-%s-%s' % (service, get_username())
    tag = os.environ.get('DOCKER_TAG', default_tag)
    os.environ['DOCKER_TAG'] = tag

    paasta_cook_image(None, service=service, soa_dir=args.yelpsoa_config_root)

    try:
        configure_and_run_docker_container(docker_client, tag, service, args)
    except errors.APIError as e:
        sys.stderr.write('Can\'t run Docker container. Error: %s\n' % str(e))
        sys.exit(1)
コード例 #16
0
ファイル: local_run.py プロジェクト: georgekola/paasta
def paasta_local_run(args):
    validate_environment()

    service = figure_out_service_name(args, soa_dir=args.yelpsoa_config_root)

    base_docker_url = get_docker_host()

    docker_client = Client(base_url=base_docker_url)

    default_tag = 'paasta-local-run-%s-%s' % (service, get_username())
    tag = os.environ.get('DOCKER_TAG', default_tag)
    os.environ['DOCKER_TAG'] = tag

    paasta_cook_image(None, service=service, soa_dir=args.yelpsoa_config_root)

    try:
        configure_and_run_docker_container(docker_client, tag, service, args)
    except errors.APIError as e:
        sys.stderr.write('Can\'t run Docker container. Error: %s\n' % str(e))
        sys.exit(1)
コード例 #17
0
def paasta_emergency_stop(args):
    """Performs an emergency stop on a given service instance on a given cluster

    Warning: This command does not permanently stop the service. The next time the service is updated
    (config change, deploy, bounce, etc.), those settings will override the emergency stop.

    If you want this stop to be permanant, adjust the relevant config file to reflect that.
    For example, this can be done for Marathon apps by setting 'instances: 0', or
    for Chronos jobs by setting 'disabled: True'. Alternatively, remove the config yaml entirely.
    """
    service = figure_out_service_name(args, soa_dir=args.yelpsoa_config_root)
    print "Performing an emergency stop on %s..." % compose_job_id(
        service, args.instance)
    output = execute_paasta_serviceinit_on_remote_master('stop',
                                                         args.cluster,
                                                         service,
                                                         args.instance,
                                                         app_id=args.appid)
    print "Output: %s" % output
    print "%s" % "\n".join(paasta_emergency_stop.__doc__.splitlines()[-7:])
    print "To start this service again asap, run:"
    print "paasta emergency-start --service %s --instance %s --cluster %s" % (
        service, args.instance, args.cluster)
コード例 #18
0
ファイル: rollback.py プロジェクト: ashwinaj/paasta
def paasta_rollback(args):
    """Call mark_for_deployment with rollback parameters
    :param args: contains all the arguments passed onto the script: service,
    cluster, instance and sha. These arguments will be verified and passed onto
    mark_for_deployment.
    """
    service = figure_out_service_name(args)
    cluster = args.cluster
    git_url = get_git_url(service)
    commit = args.commit
    given_instances = args.instances.split(",")

    if cluster in list_clusters(service):
        service_instances = list_all_instances_for_service(service)
        instances, invalid = validate_given_instances(service_instances, given_instances)

        if len(invalid) > 0:
            print PaastaColors.yellow("These instances are not valid and will be skipped: %s.\n" % (",").join(invalid))

        if len(instances) is 0:
            print PaastaColors.red("ERROR: No valid instances specified for %s.\n" % (service))
            returncode = 1

        for instance in instances:
            returncode = mark_for_deployment(
                git_url=git_url,
                cluster=cluster,
                instance=instance,
                service=service,
                commit=commit,
            )
    else:
        print PaastaColors.red("ERROR: The service %s is not deployed into cluster %s.\n" % (service, cluster))
        returncode = 1

    sys.exit(returncode)
コード例 #19
0
ファイル: logs.py プロジェクト: SegFault-Research-Lab/PaaSTA
def paasta_logs(args):
    """Print the logs for as Paasta service.
    :param args: argparse.Namespace obj created from sys.args by paasta_cli"""
    if scribereader is None:
        sys.exit(
            "Unfortunately, `paasta logs` is unavailable without Scribe."
            " We're working to support alternative logging backends in PaaSTA:"
            " follow https://github.com/Yelp/paasta/issues/64 for updates.")
    service = figure_out_service_name(args)

    if args.clusters is None:
        clusters = list_clusters(service)
    else:
        clusters = args.clusters.split(",")

    if args.components is not None:
        components = args.components.split(",")
    else:
        components = DEFAULT_COMPONENTS

    if args.debug:
        log.setLevel(logging.DEBUG)
        levels = [DEFAULT_LOGLEVEL, 'debug']
    else:
        log.setLevel(logging.WARNING)
        levels = [DEFAULT_LOGLEVEL]

    log.info("Going to get logs for %s on clusters %s" % (service, clusters))
    if args.tail:
        tail_paasta_logs(service,
                         levels,
                         components,
                         clusters,
                         raw_mode=args.raw_mode)
    else:
        print "Non-tailing actions are not yet supported"
コード例 #20
0
ファイル: info.py プロジェクト: ashwinaj/paasta
def paasta_info(args):
    """Prints general information about a service"""
    service = figure_out_service_name(args)
    print get_service_info(service)
コード例 #21
0
def paasta_info(args):
    """Prints general information about a service"""
    service = figure_out_service_name(args)
    print get_service_info(service)