def main(): args = parse_args() if args.debug: log.setLevel(logging.DEBUG) else: log.setLevel(logging.WARNING) instances = [] return_codes = [] command = args.command if (args.service_instance): service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) instances.append(instance) elif (args.service and args.instances): service = args.service instances = args.instances.split(',') else: log.error("The name of service or the name of instance to inspect is missing. Exiting.") sys.exit(1) cluster = load_system_paasta_config().get_cluster() for instance in instances: instance_type = validate_service_instance(service, instance, cluster, args.soa_dir) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, delta=args.delta, ) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) else: log.error("I calculated an instance_type of %s for %s which I don't know how to handle. Exiting." % (instance_type, compose_job_id(service, instance))) return_code = 1 return_codes.append(return_code) sys.exit(max(return_codes))
def main(): args = parse_args() if args.debug: log.setLevel(logging.DEBUG) else: log.setLevel(logging.WARNING) command = args.command service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) cluster = load_system_paasta_config().get_cluster() instance_type = validate_service_instance(service, instance, cluster, args.soa_dir) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, delta=args.delta, ) sys.exit(return_code) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) sys.exit(return_code) else: log.error( "I calculated an instance_type of %s for %s which I don't know how to handle. Exiting." % (instance_type, compose_job_id(service, instance))) sys.exit(1)
def main(): args = parse_args() if args.debug: log.setLevel(logging.DEBUG) else: log.setLevel(logging.WARNING) command = args.command service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) cluster = load_system_paasta_config().get_cluster() instance_type = validate_service_instance(service, instance, cluster, args.soa_dir) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, delta=args.delta, ) sys.exit(return_code) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) sys.exit(return_code) else: log.error("I calculated an instance_type of %s for %s which I don't know how to handle. Exiting." % (instance_type, compose_job_id(service, instance))) sys.exit(1)
def main(): args = parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.WARNING) instances = [] return_codes = [] command = args.command if (args.service_instance): service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) instances.append(instance) elif (args.service and args.instances): service = args.service instances = args.instances.split(',') else: log.error( "The name of service or the name of instance to inspect is missing. Exiting." ) sys.exit(1) # Setting up transparent cache for http API calls requests_cache.install_cache("paasta_serviceinit", backend="memory") cluster = load_system_paasta_config().get_cluster() actual_deployments = get_actual_deployments(service, args.soa_dir) for instance in instances: # For an instance, there might be multiple versions running, e.g. in crossover bouncing. # In addition, mesos master does not have information of a chronos service's git hash. # The git sha in deployment.json is simply used here. version = actual_deployments['.'.join((cluster, instance))][:8] print 'instance: %s' % PaastaColors.blue(instance) print 'Git sha: %s (desired)' % version try: instance_type = validate_service_instance(service, instance, cluster, args.soa_dir) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, delta=args.delta, ) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) else: log.error( "I calculated an instance_type of %s for %s which I don't know how to handle." % (instance_type, compose_job_id(service, instance))) return_code = 1 except Exception: log.error( 'Exception raised while looking at service %s instance %s:' % (service, instance)) log.error(traceback.format_exc()) return_code = 1 return_codes.append(return_code) sys.exit(max(return_codes))
def main() -> None: args = parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.WARNING) instances = [] return_codes = [] command = args.command if (args.service_instance): service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) instances.append(instance) elif (args.service and args.instances): service = args.service instances = args.instances.split(',') else: log.error( "The name of service or the name of instance to inspect is missing. Exiting." ) sys.exit(1) # Setting up transparent cache for http API calls requests_cache.install_cache("paasta_serviceinit", backend="memory") cluster = load_system_paasta_config().get_cluster() actual_deployments = get_actual_deployments(service, args.soa_dir) clients = PaastaClients(cached=(command == 'status')) instance_types = ['marathon', 'chronos', 'paasta_native', 'adhoc'] instance_types_map: Dict[str, List[str]] = {it: [] for it in instance_types} for instance in instances: try: instance_type = validate_service_instance( service, instance, cluster, args.soa_dir, ) except Exception: log.error( ('Exception raised while looking at service %s instance %s:' ).format(service, instance), ) log.error(traceback.format_exc()) return_codes.append(1) continue if instance_type not in instance_types: log.error( ("I calculated an instance_type of {} for {} which I don't " "know how to handle.").format( instance_type, compose_job_id(service, instance), ), ) return_codes.append(1) else: instance_types_map[instance_type].append(instance) remote_run_frameworks = None if len(instance_types_map['adhoc']) > 0: remote_run_frameworks = paasta_remote_run.remote_run_frameworks() service_config_loader = PaastaServiceConfigLoader(service) for instance_type in instance_types: if instance_type == 'marathon': job_configs = { jc.instance: jc for jc in service_config_loader.instance_configs( cluster=cluster, instance_type_class=marathon_tools.MarathonServiceConfig, ) } for instance in instance_types_map[instance_type]: try: version = get_deployment_version( actual_deployments, cluster, instance, ) paasta_print('instance: %s' % PaastaColors.blue(instance)) paasta_print('Git sha: %s (desired)' % version) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, clients=clients.marathon(), job_config=job_configs[instance], ) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, client=clients.chronos(), ) elif instance_type == 'paasta_native': return_code = paasta_native_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) elif instance_type == 'adhoc': if command != 'status': raise NotImplementedError paasta_remote_run.remote_run_list_report( service=service, instance=instance, cluster=cluster, frameworks=remote_run_frameworks, ) return_code = 0 except Exception: log.error(('Exception raised while looking at service {} ' 'instance {}:').format(service, instance), ) log.error(traceback.format_exc()) return_code = 1 return_codes.append(return_code) sys.exit(max(return_codes))
def main(): args = parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.WARNING) instances = [] return_codes = [] command = args.command if (args.service_instance): service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) instances.append(instance) elif (args.service and args.instances): service = args.service instances = args.instances.split(',') else: log.error( "The name of service or the name of instance to inspect is missing. Exiting." ) sys.exit(1) # Setting up transparent cache for http API calls requests_cache.install_cache("paasta_serviceinit", backend="memory") cluster = load_system_paasta_config().get_cluster() actual_deployments = get_actual_deployments(service, args.soa_dir) clients = PaastaClients(cached=(command == 'status')) for instance in instances: try: instance_type = validate_service_instance(service, instance, cluster, args.soa_dir) if instance_type == 'adhoc': continue version = get_deployment_version(actual_deployments, cluster, instance) paasta_print('instance: %s' % PaastaColors.blue(instance)) paasta_print('Git sha: %s (desired)' % version) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, delta=args.delta, client=clients.marathon(), ) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, client=clients.chronos(), ) elif instance_type == 'paasta_native': return_code = paasta_native_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) else: log.error( "I calculated an instance_type of %s for %s which I don't know how to handle." % (instance_type, compose_job_id(service, instance))) return_code = 1 except Exception: log.error( 'Exception raised while looking at service %s instance %s:' % (service, instance)) log.error(traceback.format_exc()) return_code = 1 return_codes.append(return_code) sys.exit(max(return_codes))
def main(): args = parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.WARNING) instances = [] return_codes = [] command = args.command if (args.service_instance): service_instance = args.service_instance service, instance, _, __ = decompose_job_id(service_instance) instances.append(instance) elif (args.service and args.instances): service = args.service instances = args.instances.split(',') else: log.error("The name of service or the name of instance to inspect is missing. Exiting.") sys.exit(1) # Setting up transparent cache for http API calls requests_cache.install_cache("paasta_serviceinit", backend="memory") cluster = load_system_paasta_config().get_cluster() actual_deployments = get_actual_deployments(service, args.soa_dir) for instance in instances: # For an instance, there might be multiple versions running, e.g. in crossover bouncing. # In addition, mesos master does not have information of a chronos service's git hash. # The git sha in deployment.json is simply used here. version = actual_deployments['.'.join((cluster, instance))][:8] print 'instance: %s' % PaastaColors.blue(instance) print 'Git sha: %s (desired)' % version try: instance_type = validate_service_instance(service, instance, cluster, args.soa_dir) if instance_type == 'marathon': return_code = marathon_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, app_id=args.app_id, delta=args.delta, ) elif instance_type == 'chronos': return_code = chronos_serviceinit.perform_command( command=command, service=service, instance=instance, cluster=cluster, verbose=args.verbose, soa_dir=args.soa_dir, ) else: log.error("I calculated an instance_type of %s for %s which I don't know how to handle." % (instance_type, compose_job_id(service, instance))) return_code = 1 except: log.error('Exception raised while looking at service %s instance %s:' % (service, instance)) log.error(traceback.format_exc()) return_code = 1 return_codes.append(return_code) sys.exit(max(return_codes))