Module Expr Str Import alias Import alias Import alias Import alias ImportFrom alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad NameLoad attr keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword AttributeLoad NameLoad attr keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Call NameLoad attr Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad attr Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str Assign NameStore BinOpMod Str Call NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad attr Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str Assign SubscriptStore NameLoad Index Str Str Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword BinOpMod Str Call NameLoad NameLoad NameLoad keyword NameLoad keyword AttributeLoad AttributeLoad NameLoad attr attr keyword Str keyword NameLoad keyword NameLoad decorator_list FunctionDef arguments args defaults body Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body FunctionDef arguments args NameParam NameParam defaults Str body Return Call NameLoad keyword NameLoad keyword NameLoad keyword Str keyword NameLoad keyword NameLoad keyword NameLoad decorator_list If Call NameLoad ListLoad UnaryOpNot NameLoad Call AttributeLoad NameLoad attr body Expr Call NameLoad keyword Call AttributeLoad Str attr ListLoad BinOpMod Str TupleLoad NameLoad NameLoad BinOpMod Str TupleLoad NameLoad IfExp NameLoad Str Str BinOpMod Str BinOpSub SubscriptLoad NameLoad Index Str Call NameLoad NameLoad BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpMod Str Call NameLoad Call AttributeLoad NameLoad attr keyword Str orelse Expr Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad If BoolOpAnd SubscriptLoad NameLoad Index Str UnaryOpNot NameLoad body Expr Call NameLoad keyword BinOpMod Str TupleLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad If CompareGt Call NameLoad SubscriptLoad NameLoad Index Str Num body Assign NameStore Call NameLoad NameLoad For NameStore SubscriptLoad NameLoad Index Str body Expr Call AttributeLoad SubscriptLoad NameLoad Index AttributeLoad NameLoad attr attr NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Expr Call NameLoad keyword BinOpMod Str TupleLoad NameLoad Call NameLoad NameLoad NameLoad For NameStore SubscriptLoad NameLoad Index Str body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad For NameStore NameLoad body If Call AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad keyword BinOpMod Str TupleLoad NameLoad AttributeLoad NameLoad attr Expr Call NameLoad keyword NameLoad keyword ListComp AttributeLoad NameLoad attr comprehension NameStore NameLoad keyword NameLoad Assign NameStore ListLoad For NameStore Call AttributeLoad NameLoad attr body If CompareNotEq NameLoad BinOpMod Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareEq Num Call NameLoad BinOpSub BinOpBitOr BinOpBitOr NameLoad NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If NameLoad body Expr Call NameLoad keyword BinOpMod Str TupleLoad NameLoad Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr If Call NameLoad ListLoad BoolOpOr NameLoad NameLoad CompareEq NameLoad Call AttributeLoad NameLoad attr CompareEq NameLoad NameLoad body Expr Call NameLoad keyword BinOpMod Str TupleLoad NameLoad NameLoad NameLoad keyword Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore Dict Str Str Str Call NameLoad Call NameLoad Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad For NameStore AttributeLoad NameLoad attr body If Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Str orelse If CompareIn NameLoad NameLoad body Assign NameStore Str orelse Assign NameStore Str Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Dict Assign NameStore Dict Assign NameStore Dict For NameStore NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Return TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam NameParam defaults Str body Return Call NameLoad keyword NameLoad keyword NameLoad keyword Str keyword Str keyword NameLoad keyword NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore ListComp NameLoad comprehension NameStore NameLoad CompareEq AttributeLoad NameLoad attr BinOpMod Str SubscriptLoad NameLoad Index Str Assign NameStore ListComp NameLoad comprehension NameStore NameLoad CompareNotEq AttributeLoad NameLoad attr BinOpMod Str SubscriptLoad NameLoad Index Str Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad If NameLoad body Assign NameStore SubscriptLoad NameLoad Index Num If CompareNotEq Call NameLoad NameLoad Num body Raise Call NameLoad BinOpMod Str Call NameLoad NameLoad Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad orelse Assign NameStore NameLoad Assign NameStore ListLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad handlers ExceptHandler type NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad Call AttributeLoad Str attr Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad Return TupleLoad Num NameLoad Assign TupleStore NameStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad If NameLoad body Assign NameStore Call NameLoad If CompareLt AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str body Expr Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword SubscriptLoad NameLoad Index Str keyword NameLoad orelse If CompareGt AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str body Assign NameStore Call NameLoad BinOpSub Call NameLoad Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Num Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr Call NameLoad SubscriptLoad NameLoad Slice NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice NameLoad Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr Call NameLoad SubscriptLoad NameLoad Slice NameLoad Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad Assign SubscriptStore NameLoad Index AttributeLoad NameLoad attr Call NameLoad SubscriptLoad NameLoad Slice NameLoad Assign NameStore SubscriptLoad NameLoad Slice NameLoad For NameStore AttributeLoad NameLoad attr body If CompareNotIn NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad For NameStore Call AttributeLoad NameLoad attr body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad TryExcept body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad Call AttributeLoad Str attr Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad Return TupleLoad Num NameLoad TryExcept body With Call AttributeLoad NameLoad attr NameLoad body Expr Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str NameLoad Return TupleLoad Num BinOpMod Str NameLoad handlers ExceptHandler type NameLoad body Assign NameStore ListLoad BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad Call AttributeLoad NameLoad attr attr attr Str For NameStore NameLoad body Expr Call NameLoad NameLoad keyword Str Raise Return TupleLoad Num Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad NameLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Assign NameStore Call AttributeLoad Str attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return TupleLoad Num NameLoad Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str NameLoad Return Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword Call AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr NameLoad keyword Call AttributeLoad NameLoad attr NameLoad keyword Call AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr NameLoad keyword NameLoad decorator_list FunctionDef arguments args defaults body Expr Str Assign NameStore Call NameLoad Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr TryExcept body Assign TupleStore NameStore NameStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr Num Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Call AttributeLoad Call NameLoad attr keyword NameLoad handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr Call AttributeLoad Call NameLoad attr Expr Call AttributeLoad NameLoad attr Num ExceptHandler type NameLoad body Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr Call AttributeLoad Call NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Num TryExcept body Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore IfExp NameLoad AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad AttributeLoad NameLoad attr attr Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Num handlers ExceptHandler type TupleLoad NameLoad NameLoad NameLoad NameLoad body Import alias Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad NameLoad attr Num decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A 
Usage: ./setup_marathon_job.py <service.instance> [options]

Deploy a service instance to Marathon from a configuration file.
Attempts to load the marathon configuration at
/etc/paasta/marathon.json, and read
from the soa_dir /nail/etc/services by default.

This script will attempt to load a service's configuration
from the soa_dir and generate a marathon job configuration for it,
as well as handle deploying that configuration with a bounce strategy
if there's an old version of the service. To determine whether or not
a deployment is 'old', each marathon job has a complete id of
service.instance.configuration_hash, where configuration_hash
is an MD5 hash of the configuration dict to be sent to marathon (without
the configuration_hash in the id field, of course- we change that after
the hash is calculated).

The script will emit a sensu event based on how the deployment went-
if something went wrong, it'll alert the team responsible for the service
(as defined in that service's monitoring.yaml), and it'll send resolves
when the deployment goes alright.

Command line options:

- -d <SOA_DIR>, --soa-dir <SOA_DIR>: Specify a SOA config dir to read from
- -v, --verbose: Verbose output
 N/A argparse N/A logging N/A sys N/A traceback collections defaultdict N/A pysensu_yelp paasta_tools bounce_lib paasta_tools drain_lib paasta_tools marathon_tools paasta_tools monitoring_tools paasta_tools.marathon_tools kill_given_tasks paasta_tools.utils _log paasta_tools.utils compose_job_id paasta_tools.utils decompose_job_id paasta_tools.utils InvalidInstanceConfig paasta_tools.utils InvalidJobNameError paasta_tools.utils load_system_paasta_config paasta_tools.utils NoConfigurationForServiceError paasta_tools.utils NoDeploymentsAvailable paasta_tools.utils NoDockerImageError paasta_tools.utils SPACER N/A log N/A N/A logging getLogger __main__ N/A N/A N/A logging basicConfig parse_args N/A N/A N/A N/A N/A parser N/A N/A argparse ArgumentParser description Creates marathon jobs. N/A N/A N/A parser add_argument service_instance help The marathon instance of the service to create or update metavar N/A SERVICE%sINSTANCE SPACER N/A N/A N/A parser add_argument -d --soa-dir dest soa_dir metavar SOA_DIR default N/A marathon_tools DEFAULT_SOA_DIR help define a different soa config directory N/A N/A N/A parser add_argument -v --verbose action store_true dest verbose default False N/A args N/A N/A parser parse_args N/A args N/A send_event N/A N/A name instance soa_dir status output N/A N/A N/A Send an event to sensu via pysensu_yelp with the given information.

    :param name: The service name the event is about
    :param instance: The instance of the service the event is about
    :param soa_dir: The service directory to read monitoring information from
    :param status: The status to emit for this event
    :param output: The output to emit for this event
     N/A cluster N/A N/A N/A load_system_paasta_config get_cluster N/A monitoring_overrides N/A N/A N/A N/A marathon_tools load_marathon_service_config name instance cluster soa_dir soa_dir load_deployments False get_monitoring N/A N/A monitoring_overrides N/A check_every 10s N/A N/A monitoring_overrides N/A alert_after 10m N/A check_name N/A setup_marathon_job.%s N/A compose_job_id name instance N/A N/A N/A monitoring_tools send_event name check_name monitoring_overrides status output soa_dir N/A send_sensu_bounce_keepalive N/A N/A service instance cluster soa_dir N/A N/A N/A Send a Sensu event with a special ``ttl``, to let Sensu know that
    the everything is fine. This event is **not** fired when the bounce is in
    progress.

    If the bounce goes on for too long, this the ``ttl`` will expire and Sensu
    will emit a new event saying that this one didn't check in within the expected
    time-to-live. N/A ttl 1h N/A monitoring_overrides N/A N/A N/A N/A marathon_tools load_marathon_service_config service service instance instance cluster cluster soa_dir soa_dir load_deployments False get_monitoring N/A N/A monitoring_overrides N/A check_every 30s N/A N/A monitoring_overrides N/A alert_after 2m N/A N/A monitoring_overrides N/A runbook http://y/paasta-troubleshooting N/A N/A monitoring_overrides N/A tip Check out `paasta logs`. If the bounce hasn't made progress, it may mean that the new version isn't healthy. N/A N/A monitoring_overrides N/A team noop N/A N/A monitoring_overrides N/A notification_email kwa@yelp.com N/A N/A N/A monitoring_tools send_event service service check_name N/A paasta_bounce_progress.%s N/A compose_job_id service instance overrides monitoring_overrides status N/A N/A pysensu_yelp Status OK output The bounce is in a steady state soa_dir soa_dir ttl ttl N/A get_main_marathon_config N/A N/A N/A N/A N/A N/A N/A log debug Reading marathon configuration N/A marathon_config N/A N/A marathon_tools load_marathon_config N/A N/A N/A log info Marathon config is: %s marathon_config N/A marathon_config N/A do_bounce N/A N/A bounce_func drain_method config new_app_running happy_new_tasks old_app_live_happy_tasks old_app_live_unhappy_tasks old_app_draining_tasks service bounce_method serviceinstance cluster instance marathon_jobid client soa_dir N/A N/A log_bounce_action N/A N/A line level N/A debug N/A N/A N/A _log service service line line component deploy level level cluster cluster instance instance N/A N/A N/A any N/A N/A new_app_running N/A N/A old_app_live_happy_tasks keys N/A N/A N/A log_bounce_action line N/A N/A join N/A N/A %s bounce in progress on %s. N/A bounce_method serviceinstance N/A New marathon app %s %s. N/A marathon_jobid N/A new_app_running exists not created yet N/A %d new tasks to bring up. N/A N/A config N/A instances N/A len happy_new_tasks N/A %d old tasks receiving traffic and happy. N/A len N/A N/A bounce_lib flatten_tasks old_app_live_happy_tasks N/A %d old tasks unhappy. N/A len N/A N/A bounce_lib flatten_tasks old_app_live_unhappy_tasks N/A %d old tasks draining. N/A len N/A N/A bounce_lib flatten_tasks old_app_draining_tasks N/A %d old apps. N/A len N/A N/A old_app_live_happy_tasks keys level event N/A N/A N/A send_sensu_bounce_keepalive service service instance instance cluster cluster soa_dir soa_dir N/A all_draining_tasks N/A set N/A actions N/A bounce_func new_config config new_app_running new_app_running happy_new_tasks happy_new_tasks old_app_live_happy_tasks old_app_live_happy_tasks old_app_live_unhappy_tasks old_app_live_unhappy_tasks N/A N/A N/A actions N/A create_app N/A new_app_running N/A N/A N/A log_bounce_action line N/A %s bounce creating new app with app_id %s N/A bounce_method marathon_jobid N/A N/A N/A bounce_lib create_marathon_app marathon_jobid config client N/A N/A N/A len N/A actions N/A tasks_to_drain 0 N/A N/A tasks_to_drain_by_app_id N/A defaultdict set N/A task N/A actions N/A tasks_to_drain N/A N/A N/A N/A N/A tasks_to_drain_by_app_id N/A N/A task app_id add task N/A N/A app_id tasks N/A N/A tasks_to_drain_by_app_id items N/A N/A N/A log_bounce_action line N/A %s bounce draining %d old tasks with app_id %s N/A bounce_method N/A len tasks app_id N/A task N/A actions N/A tasks_to_drain N/A N/A N/A N/A all_draining_tasks add task N/A N/A N/A drain_method drain task N/A N/A app tasks N/A N/A old_app_draining_tasks items N/A N/A task tasks N/A N/A N/A N/A all_draining_tasks add task N/A tasks_to_kill N/A set N/A task all_draining_tasks N/A N/A N/A N/A drain_method is_safe_to_kill task N/A N/A N/A N/A tasks_to_kill add task N/A N/A log_bounce_action line N/A %s bounce killing drained task %s N/A bounce_method N/A task id N/A N/A kill_given_tasks client client task_ids N/A N/A task id N/A task tasks_to_kill scale True N/A apps_to_kill N/A N/A app N/A N/A old_app_live_happy_tasks keys N/A N/A N/A app N/A /%s marathon_jobid N/A N/A live_happy_tasks N/A old_app_live_happy_tasks N/A app N/A live_unhappy_tasks N/A old_app_live_unhappy_tasks N/A app N/A draining_tasks N/A old_app_draining_tasks N/A app N/A N/A 0 N/A len N/A N/A N/A live_happy_tasks live_unhappy_tasks draining_tasks tasks_to_kill N/A N/A N/A N/A apps_to_kill append app N/A apps_to_kill N/A N/A N/A log_bounce_action line N/A %s bounce removing old unused apps with app_ids: %s N/A bounce_method N/A N/A ,  join apps_to_kill N/A N/A N/A bounce_lib kill_old_ids apps_to_kill client N/A all_old_tasks N/A N/A set union N/A set N/A N/A old_app_live_happy_tasks values N/A all_old_tasks N/A N/A set union all_old_tasks N/A N/A old_app_live_unhappy_tasks values N/A all_old_tasks N/A N/A set union all_old_tasks N/A N/A old_app_draining_tasks values N/A N/A all N/A N/A apps_to_kill tasks_to_kill N/A apps_to_kill N/A N/A old_app_live_happy_tasks keys N/A tasks_to_kill all_old_tasks N/A N/A N/A log_bounce_action line N/A %s bounce on %s finishing. Now running %s N/A bounce_method serviceinstance marathon_jobid level event N/A get_old_happy_unhappy_draining_tasks_for_app N/A N/A app drain_method service nerve_ns bounce_health_params system_paasta_config N/A N/A N/A tasks_by_state N/A happy unhappy draining N/A set N/A set N/A set N/A happy_tasks N/A N/A bounce_lib get_happy_tasks app service nerve_ns system_paasta_config bounce_health_params N/A task N/A app tasks N/A N/A N/A N/A drain_method is_draining task N/A N/A state draining N/A N/A N/A task happy_tasks N/A N/A state happy N/A N/A state unhappy N/A N/A N/A N/A tasks_by_state N/A state add task N/A tasks_by_state N/A get_old_happy_unhappy_draining_tasks N/A N/A other_apps drain_method service nerve_ns bounce_health_params system_paasta_config N/A N/A N/A Split tasks from old apps into 3 categories:
      - live (not draining) and happy (according to get_happy_tasks)
      - live (not draining) and unhappy
      - draining
     N/A old_app_live_happy_tasks N/A N/A old_app_live_unhappy_tasks N/A N/A old_app_draining_tasks N/A N/A app other_apps N/A N/A tasks_by_state N/A get_old_happy_unhappy_draining_tasks_for_app app drain_method service nerve_ns bounce_health_params system_paasta_config N/A N/A old_app_live_happy_tasks N/A N/A app id N/A tasks_by_state N/A happy N/A N/A old_app_live_unhappy_tasks N/A N/A app id N/A tasks_by_state N/A unhappy N/A N/A old_app_draining_tasks N/A N/A app id N/A tasks_by_state N/A draining N/A N/A old_app_live_happy_tasks old_app_live_unhappy_tasks old_app_draining_tasks N/A deploy_service N/A N/A service instance marathon_jobid config client bounce_method drain_method_name drain_method_params nerve_ns bounce_health_params soa_dir N/A N/A N/A Deploy the service to marathon, either directly or via a bounce if needed.
    Called by setup_service when it's time to actually deploy.

    :param service: The name of the service to deploy
    :param instance: The instance of the service to deploy
    :param marathon_jobid: Full id of the marathon job
    :param config: The complete configuration dict to send to marathon
    :param client: A MarathonClient object
    :param bounce_method: The bounce method to use, if needed
    :param drain_method_name: The name of the traffic draining method to use.
    :param nerve_ns: The nerve namespace to look in.
    :param bounce_health_params: A dictionary of options for bounce_lib.get_happy_tasks.
    :returns: A tuple of (status, output) to be used with send_sensu_event log_deploy_error N/A N/A errormsg level N/A event N/A N/A N/A _log service service line errormsg component deploy level event cluster cluster instance instance N/A N/A short_id N/A N/A marathon_tools format_job_id service instance N/A system_paasta_config N/A load_system_paasta_config N/A cluster N/A N/A system_paasta_config get_cluster N/A existing_apps N/A N/A marathon_tools get_matching_apps service instance client embed_failures True N/A new_app_list N/A a N/A a existing_apps N/A N/A a id N/A /%s N/A config N/A id N/A other_apps N/A a N/A a existing_apps N/A N/A a id N/A /%s N/A config N/A id N/A serviceinstance N/A %s.%s N/A service instance N/A new_app_list N/A N/A new_app N/A new_app_list N/A 0 N/A N/A N/A len new_app_list 1 N/A N/A N/A ValueError N/A Only expected one app per ID; found %d N/A len new_app_list N/A new_app_running True N/A happy_new_tasks N/A N/A bounce_lib get_happy_tasks new_app service nerve_ns system_paasta_config bounce_health_params N/A N/A new_app_running False N/A happy_new_tasks N/A N/A N/A N/A drain_method N/A N/A drain_lib get_drain_method drain_method_name service service instance instance nerve_ns nerve_ns drain_method_params drain_method_params N/A N/A N/A KeyError N/A N/A errormsg N/A ERROR: drain_method not recognized: %s. Must be one of (%s) N/A drain_method_name N/A N/A ,  join N/A N/A drain_lib list_drain_methods N/A N/A log_deploy_error errormsg N/A N/A 1 errormsg N/A N/A old_app_live_happy_tasks old_app_live_unhappy_tasks old_app_draining_tasks N/A get_old_happy_unhappy_draining_tasks other_apps drain_method service nerve_ns bounce_health_params system_paasta_config N/A new_app_running N/A N/A protected_draining_tasks N/A set N/A N/A N/A new_app instances N/A config N/A instances N/A N/A N/A N/A client scale_app app_id N/A new_app id instances N/A config N/A instances force True N/A N/A N/A N/A new_app instances N/A config N/A instances N/A N/A num_tasks_to_scale N/A max N/A N/A min N/A len N/A new_app tasks N/A new_app instances N/A config N/A instances 0 N/A task_dict N/A get_old_happy_unhappy_draining_tasks_for_app new_app drain_method service nerve_ns bounce_health_params system_paasta_config N/A scaling_app_happy_tasks N/A list N/A task_dict N/A happy N/A scaling_app_unhappy_tasks N/A list N/A task_dict N/A unhappy N/A scaling_app_draining_tasks N/A list N/A task_dict N/A draining N/A tasks_to_move_draining N/A min N/A len scaling_app_draining_tasks num_tasks_to_scale N/A N/A old_app_draining_tasks N/A N/A new_app id N/A set N/A scaling_app_draining_tasks N/A tasks_to_move_draining N/A N/A N/A protected_draining_tasks update N/A scaling_app_draining_tasks N/A tasks_to_move_draining N/A num_tasks_to_scale N/A num_tasks_to_scale tasks_to_move_draining N/A tasks_to_move_unhappy N/A min N/A len scaling_app_unhappy_tasks num_tasks_to_scale N/A N/A old_app_live_unhappy_tasks N/A N/A new_app id N/A set N/A scaling_app_unhappy_tasks N/A tasks_to_move_unhappy N/A num_tasks_to_scale N/A num_tasks_to_scale tasks_to_move_unhappy N/A tasks_to_move_happy N/A min N/A len scaling_app_happy_tasks num_tasks_to_scale N/A N/A old_app_live_happy_tasks N/A N/A new_app id N/A set N/A scaling_app_happy_tasks N/A tasks_to_move_happy N/A happy_new_tasks N/A scaling_app_happy_tasks N/A tasks_to_move_happy N/A task N/A new_app tasks N/A N/A N/A task protected_draining_tasks N/A N/A N/A N/A drain_method stop_draining task N/A tasks N/A N/A old_app_draining_tasks values N/A N/A task tasks N/A N/A N/A N/A drain_method drain task N/A N/A N/A N/A N/A bounce_func N/A N/A bounce_lib get_bounce_method_func bounce_method N/A N/A N/A KeyError N/A N/A errormsg N/A ERROR: bounce_method not recognized: %s. Must be one of (%s) N/A bounce_method N/A N/A ,  join N/A N/A bounce_lib list_bounce_methods N/A N/A log_deploy_error errormsg N/A N/A 1 errormsg N/A N/A N/A N/A N/A bounce_lib bounce_lock_zookeeper short_id N/A N/A N/A do_bounce bounce_func bounce_func drain_method drain_method config config new_app_running new_app_running happy_new_tasks happy_new_tasks old_app_live_happy_tasks old_app_live_happy_tasks old_app_live_unhappy_tasks old_app_live_unhappy_tasks old_app_draining_tasks old_app_draining_tasks service service bounce_method bounce_method serviceinstance serviceinstance cluster cluster instance instance marathon_jobid marathon_jobid client client soa_dir soa_dir N/A N/A N/A N/A bounce_lib LockHeldException N/A N/A N/A N/A log error Instance %s already being bounced. Exiting short_id N/A N/A 1 N/A Instance %s is already being bounced. short_id N/A N/A N/A Exception N/A N/A loglines N/A N/A Exception raised during deploy of service %s: service N/A N/A N/A loglines extend N/A N/A N/A N/A N/A N/A traceback format_exc rstrip split N/A logline loglines N/A N/A N/A log_deploy_error logline level debug N/A N/A N/A 0 Service deployed. N/A setup_service N/A N/A service instance client marathon_config service_marathon_config soa_dir N/A N/A N/A Setup the service instance given and attempt to deploy it, if possible.
    Doesn't do anything if the service is already in Marathon and hasn't changed.
    If it's not, attempt to find old instances of the service and bounce them.

    :param service: The service name to setup
    :param instance: The instance of the service to setup
    :param client: A MarathonClient object
    :param marathon_config: The marathon configuration dict
    :param service_marathon_config: The service instance's configuration dict
    :returns: A tuple of (status, output) to be used with send_sensu_event N/A N/A N/A log info Setting up instance %s for service %s instance service N/A N/A N/A marathon_app_dict N/A N/A service_marathon_config format_marathon_app_dict N/A N/A N/A NoDockerImageError N/A N/A error_msg N/A N/A Docker image for {0}.{1} not in deployments.json. Exiting. Has Jenkins deployed it?
 format service instance N/A N/A N/A log error error_msg N/A N/A 1 error_msg N/A full_id N/A marathon_app_dict N/A id N/A service_namespace_config N/A N/A marathon_tools load_service_namespace_config service instance N/A N/A N/A log info Desired Marathon instance id: %s full_id N/A N/A deploy_service service service instance instance marathon_jobid full_id config marathon_app_dict client client bounce_method N/A N/A service_marathon_config get_bounce_method drain_method_name N/A N/A service_marathon_config get_drain_method service_namespace_config drain_method_params N/A N/A service_marathon_config get_drain_method_params service_namespace_config nerve_ns N/A N/A service_marathon_config get_nerve_namespace bounce_health_params N/A N/A service_marathon_config get_bounce_health_params service_namespace_config soa_dir soa_dir N/A main N/A N/A N/A N/A N/A Attempt to set up the marathon service instance given.
    Exits 1 if the deployment failed.
    This is done in the following order:

    - Load the marathon configuration
    - Connect to marathon
    - Load the service instance's configuration
    - Create the complete marathon job configuration
    - Deploy/bounce the service
    - Emit an event about the deployment to sensu N/A args N/A parse_args N/A soa_dir N/A args soa_dir N/A N/A args verbose N/A N/A N/A N/A log setLevel N/A logging DEBUG N/A N/A N/A N/A log setLevel N/A logging WARNING N/A N/A N/A N/A service instance _ __ N/A decompose_job_id N/A args service_instance N/A N/A N/A InvalidJobNameError N/A N/A N/A N/A log error N/A Invalid service instance specified. Format is service%sinstance. SPACER N/A N/A N/A sys exit 1 N/A marathon_config N/A get_main_marathon_config N/A client N/A N/A marathon_tools get_marathon_client N/A N/A marathon_config get_url N/A N/A marathon_config get_username N/A N/A marathon_config get_password N/A N/A N/A service_instance_config N/A N/A marathon_tools load_marathon_service_config service instance N/A N/A N/A load_system_paasta_config get_cluster soa_dir soa_dir N/A N/A N/A NoDeploymentsAvailable N/A N/A N/A N/A log debug N/A No deployments found for %s in cluster %s. Skipping. N/A N/A args service_instance N/A N/A N/A load_system_paasta_config get_cluster N/A N/A N/A sys exit 0 N/A N/A NoConfigurationForServiceError N/A N/A error_msg N/A Could not read marathon configuration file for %s in cluster %s N/A N/A args service_instance N/A N/A N/A load_system_paasta_config get_cluster N/A N/A N/A log error error_msg N/A N/A N/A sys exit 1 N/A N/A N/A N/A status output N/A setup_service service instance client marathon_config service_instance_config soa_dir N/A sensu_status N/A status N/A N/A pysensu_yelp Status CRITICAL N/A N/A pysensu_yelp Status OK N/A N/A send_event service instance soa_dir sensu_status output N/A N/A N/A sys exit 0 N/A N/A N/A N/A KeyError TypeError AttributeError InvalidInstanceConfig N/A N/A traceback N/A error_str N/A N/A traceback format_exc N/A N/A N/A log error error_str N/A N/A send_event service instance soa_dir N/A N/A pysensu_yelp Status CRITICAL error_str N/A N/A N/A sys exit 0 N/A N/A N/A __name__ __main__ N/A N/A N/A main