def call_load_paasta_native_job_config(context): context.new_config = native_scheduler.load_paasta_native_job_config( service=context.service, instance=context.instance, cluster=context.cluster, soa_dir=context.soa_dir, )
def get_paasta_native_services_running_here_for_nerve( cluster: Optional[str], soa_dir: str, hostname: Optional[str] = None, ) -> Sequence[Tuple[str, ServiceNamespaceConfig]]: if not cluster: try: system_paasta_config = load_system_paasta_config() cluster = system_paasta_config.get_cluster() # In the cases where there is *no* cluster or in the case # where there isn't a Paasta configuration file at *all*, then # there must be no native services running here, so we catch # these custom exceptions and return []. except (PaastaNotConfiguredError): return [] if not system_paasta_config.get_register_native_services(): return [] # When a cluster is defined in mesos, let's iterate through paasta_native services paasta_native_services = paasta_native_services_running_here( hostname=hostname) nerve_list = [] for name, instance, port in paasta_native_services: try: job_config = load_paasta_native_job_config( service=name, instance=instance, cluster=cluster, load_deployments=False, soa_dir=soa_dir, ) for registration in job_config.get_registrations(): reg_service, reg_namespace, _, __ = decompose_job_id( registration) nerve_dict = load_service_namespace_config( service=reg_service, namespace=reg_namespace, soa_dir=soa_dir, ) if not nerve_dict.is_in_smartstack(): continue nerve_dict['port'] = port nerve_list.append((registration, nerve_dict)) except KeyError: continue # SOA configs got deleted for this app, it'll get cleaned up return nerve_list
def read_all_registrations_for_service_instance(service, instance, cluster=None, soa_dir=DEFAULT_SOA_DIR): """Retreive all registrations as fully specified name.instance pairs for a particular service instance. For example, the 'main' paasta instance of the 'test' service may register in the 'test.main' namespace as well as the 'other_svc.main' namespace. If one is not defined in the config file, returns a list containing name.instance instead. """ if not cluster: cluster = load_system_paasta_config().get_cluster() job_config = load_paasta_native_job_config( service=service, instance=instance, cluster=cluster, load_deployments=False, soa_dir=soa_dir, ) return job_config.get_registrations()