def status_marathon_job_verbose(service, instance, client, cluster, soa_dir): """Returns detailed information about a marathon apps for a service and instance. Does not make assumptions about what the *exact* appid is, but instead does a fuzzy match on any marathon apps that match the given service.instance""" all_tasks = [] all_output = [] # For verbose mode, we want to see *any* matching app. As it may # not be the one that we think should be deployed. For example # during a bounce we want to see the old and new ones. for app_id in marathon_tools.get_matching_appids(service, instance, client): if marathon_tools.is_app_id_running(app_id, client): app = client.get_app(app_id) tasks, output = get_verbose_status_of_marathon_app( marathon_client=client, app=app, service=service, instance=instance, cluster=cluster, soa_dir=soa_dir ) all_tasks.extend(tasks) all_output.append(output) else: all_output.append("Warning: App %s is not running yet." % app_id) return all_tasks, "\n".join(all_output)
def get_bouncing_status(service, instance, client, job_config): # embed_tasks=True here so that we're making the same HTTP call as the other parts of this code, so the call can be # cached. apps = marathon_tools.get_matching_appids(service, instance, client, embed_tasks=True) app_count = len(apps) bounce_method = job_config.get_bounce_method() return bouncing_status_human(app_count, bounce_method)
def marathon_instance_status(instance_status, service, instance, verbose): apps = marathon_tools.get_matching_appids(service, instance, settings.marathon_client) job_config = marathon_tools.load_marathon_service_config( service, instance, settings.cluster, soa_dir=settings.soa_dir) # bouncing status can be inferred from app_count, ref get_bouncing_status instance_status['app_count'] = len(apps) instance_status['bounce_method'] = job_config.get_bounce_method() instance_status['desired_state'] = job_config.get_desired_state() instance_status['marathon'] = marathon_job_status(settings.marathon_client, job_config)
def get_bouncing_status(service, instance, client, job_config): apps = marathon_tools.get_matching_appids(service, instance, client) bounce_method = job_config.get_bounce_method() app_count = len(apps) if app_count == 0: return PaastaColors.red("Stopped") elif app_count == 1: return PaastaColors.green("Running") elif app_count > 1: return PaastaColors.yellow("Bouncing (%s)" % bounce_method) else: return PaastaColors.red("Unknown (count: %s)" % app_count)
def marathon_instance_status(instance_status, service, instance, verbose): mstatus = {} apps = marathon_tools.get_matching_appids(service, instance, settings.marathon_client) job_config = marathon_tools.load_marathon_service_config( service, instance, settings.cluster, soa_dir=settings.soa_dir) # bouncing status can be inferred from app_count, ref get_bouncing_status mstatus['app_count'] = len(apps) mstatus['desired_state'] = job_config.get_desired_state() mstatus['bounce_method'] = job_config.get_bounce_method() marathon_job_status(mstatus, settings.marathon_client, job_config) return mstatus
def status_marathon_job_verbose(service, instance, client): """Returns detailed information about a marathon apps for a service and instance. Does not make assumptions about what the *exact* appid is, but instead does a fuzzy match on any marathon apps that match the given service.instance""" all_tasks = [] all_output = [] # For verbose mode, we want to see *any* matching app. As it may # not be the one that we think should be deployed. For example # during a bounce we want to see the old and new ones. for appid in marathon_tools.get_matching_appids(service, instance, client): app = client.get_app(appid) tasks, output = get_verbose_status_of_marathon_app(app) all_tasks.extend(tasks) all_output.append(output) return all_tasks, "\n".join(all_output)
def marathon_instance_status( instance_status: Mapping[str, Any], service: str, instance: str, verbose: bool, ) -> Mapping[str, Any]: mstatus: Dict[str, Any] = {} job_config = marathon_tools.load_marathon_service_config( service, instance, settings.cluster, soa_dir=settings.soa_dir, ) client = settings.marathon_clients.get_current_client_for_service(job_config) apps = marathon_tools.get_matching_appids(service, instance, client) # bouncing status can be inferred from app_count, ref get_bouncing_status mstatus['app_count'] = len(apps) mstatus['desired_state'] = job_config.get_desired_state() mstatus['bounce_method'] = job_config.get_bounce_method() marathon_job_status(mstatus, client, job_config, verbose) return mstatus
def get_bouncing_status(service, instance, client, job_config): apps = marathon_tools.get_matching_appids(service, instance, client) app_count = len(apps) bounce_method = job_config.get_bounce_method() return bouncing_status_human(app_count, bounce_method)