code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def get_authenticating_services(soa_dir: str = DEFAULT_SOA_DIR) -> Set[str]: """Load list of services participating in authenticated traffic""" authenticating_services_conf_path = os.path.join(soa_dir, "authenticating.yaml") config = service_configuration_lib.read_yaml_file(authenticating_services_conf_path...
Load list of services participating in authenticated traffic
get_authenticating_services
python
Yelp/paasta
paasta_tools/kubernetes_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes_tools.py
Apache-2.0
def add_volumes_for_authenticating_services( service_name: str, config_volumes: List[ProjectedSAVolume], soa_dir: str = DEFAULT_SOA_DIR, ) -> List[ProjectedSAVolume]: """Add projected service account volume to the list of volumes if service participates in authenticated traffic. In case of changes, ...
Add projected service account volume to the list of volumes if service participates in authenticated traffic. In case of changes, a new list is returned, no updates in-place. :param str service_name: name of the service :param List[ProjectedSAVolume] config_volumes: existing projected volumes from serv...
add_volumes_for_authenticating_services
python
Yelp/paasta
paasta_tools/kubernetes_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes_tools.py
Apache-2.0
def get_healthcheck_mode(self) -> str: """Get the healthcheck mode for the service. In most cases, this will match the mode of the service, but we do provide the opportunity for users to specify both. Default to the mode if no healthcheck_mode is specified. """ healthcheck_mode =...
Get the healthcheck mode for the service. In most cases, this will match the mode of the service, but we do provide the opportunity for users to specify both. Default to the mode if no healthcheck_mode is specified.
get_healthcheck_mode
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_mode(self) -> str: """Get the mode that the service runs in and check that we support it. If the mode is not specified, we check whether the service uses smartstack in order to determine the appropriate default value. If proxy_port is specified in the config, the service uses sma...
Get the mode that the service runs in and check that we support it. If the mode is not specified, we check whether the service uses smartstack in order to determine the appropriate default value. If proxy_port is specified in the config, the service uses smartstack, and we can thus safely assume...
get_mode
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_longest_timeout_ms(self) -> int: """Calculate the longest amount of time a connection to this service might stay open.""" return max( [self.get_timeout_server_ms()] + list(self.get("endpoint_timeouts", {}).values()) )
Calculate the longest amount of time a connection to this service might stay open.
get_longest_timeout_ms
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_drain_method(self, service_namespace_config: ServiceNamespaceConfig) -> str: """Get the drain method specified in the service's configuration. :param service_config: The service instance's configuration dictionary :returns: The drain method specified in the config, or 'noop' if not spec...
Get the drain method specified in the service's configuration. :param service_config: The service instance's configuration dictionary :returns: The drain method specified in the config, or 'noop' if not specified
get_drain_method
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_drain_method_params( self, service_namespace_config: ServiceNamespaceConfig ) -> Dict: """Get the drain method parameters specified in the service's configuration. :param service_config: The service instance's configuration dictionary :returns: The drain_method_params dictio...
Get the drain method parameters specified in the service's configuration. :param service_config: The service instance's configuration dictionary :returns: The drain_method_params dictionary specified in the config, or {} if not specified
get_drain_method_params
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_instances(self, with_limit: bool = True) -> int: """Gets the number of instances for a service, ignoring whether the user has requested the service to be started or stopped""" if self.is_autoscaling_enabled(): autoscaled_instances = self.get_autoscaled_instances() ...
Gets the number of instances for a service, ignoring whether the user has requested the service to be started or stopped
get_instances
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_desired_instances(self) -> int: """Get the number of instances specified in zookeeper or the service's configuration. If the number of instances in zookeeper is less than min_instances, returns min_instances. If the number of instances in zookeeper is greater than max_instances, returns ...
Get the number of instances specified in zookeeper or the service's configuration. If the number of instances in zookeeper is less than min_instances, returns min_instances. If the number of instances in zookeeper is greater than max_instances, returns max_instances. Defaults to 0 if not specif...
get_desired_instances
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_healthcheck_for_instance( service: str, instance: str, service_manifest: LongRunningServiceConfig, random_port: int, soa_dir: str = DEFAULT_SOA_DIR, ) -> Tuple[Optional[str], Optional[str]]: """ Returns healthcheck for a given service instance in the form of a tuple (mode, healthchec...
Returns healthcheck for a given service instance in the form of a tuple (mode, healthcheck_command) or (None, None) if no healthcheck
get_healthcheck_for_instance
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def load_service_namespace_config( service: str, namespace: str, soa_dir: str = DEFAULT_SOA_DIR ) -> ServiceNamespaceConfig: """Attempt to read the configuration for a service's namespace in a more strict fashion. Retrieves the following keys: - proxy_port: the proxy port defined for the given namespa...
Attempt to read the configuration for a service's namespace in a more strict fashion. Retrieves the following keys: - proxy_port: the proxy port defined for the given namespace - healthcheck_mode: the mode for the healthcheck (http or tcp) - healthcheck_port: An alternate port to use for health checki...
load_service_namespace_config
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_proxy_port_for_instance( service_config: LongRunningServiceConfig, ) -> Optional[int]: """Get the proxy_port defined in the first namespace configuration for a service instance. This means that the namespace first has to be loaded from the service instance's configuration, and then the prox...
Get the proxy_port defined in the first namespace configuration for a service instance. This means that the namespace first has to be loaded from the service instance's configuration, and then the proxy_port has to loaded from the smartstack configuration for that namespace. :param service_config:...
get_proxy_port_for_instance
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def host_passes_blacklist( host_attributes: Mapping[str, str], blacklist: DeployBlacklist ) -> bool: """ :param host: A single host attributes dict :param blacklist: A list of lists like [["location_type", "location"], ["foo", "bar"]] :returns: boolean, True if the host gets passed the blacklist ...
:param host: A single host attributes dict :param blacklist: A list of lists like [["location_type", "location"], ["foo", "bar"]] :returns: boolean, True if the host gets passed the blacklist
host_passes_blacklist
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def host_passes_whitelist( host_attributes: Mapping[str, str], whitelist: DeployWhitelist ) -> bool: """ :param host: A single host attributes dict. :param whitelist: A 2 item list like ["location_type", ["location1", 'location2']] :returns: boolean, True if the host gets past the whitelist """ ...
:param host: A single host attributes dict. :param whitelist: A 2 item list like ["location_type", ["location1", 'location2']] :returns: boolean, True if the host gets past the whitelist
host_passes_whitelist
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_all_namespaces( soa_dir: str = DEFAULT_SOA_DIR, ) -> Sequence[Tuple[str, ServiceNamespaceConfig]]: """Get all the smartstack namespaces across all services. This is mostly so synapse can get everything it needs in one call. :param soa_dir: The SOA config directory to read from :returns: A l...
Get all the smartstack namespaces across all services. This is mostly so synapse can get everything it needs in one call. :param soa_dir: The SOA config directory to read from :returns: A list of tuples of the form (service.namespace, namespace_config)
get_all_namespaces
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_all_namespaces_for_service( service: str, soa_dir: str = DEFAULT_SOA_DIR, full_name: bool = True ) -> Sequence[Tuple[str, ServiceNamespaceConfig]]: """Get all the smartstack namespaces listed for a given service name. :param service: The service name :param soa_dir: The SOA config directory to ...
Get all the smartstack namespaces listed for a given service name. :param service: The service name :param soa_dir: The SOA config directory to read from :param full_name: A boolean indicating if the service name should be prepended to the namespace in the returned tuples as described...
get_all_namespaces_for_service
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def get_expected_instance_count_for_namespace( service: str, namespace: str, instance_type_class: Type[LongRunningServiceConfig], cluster: str = None, soa_dir: str = DEFAULT_SOA_DIR, ) -> int: """Get the number of expected instances for a namespace, based on the number of instances set to ru...
Get the number of expected instances for a namespace, based on the number of instances set to run on that namespace as specified in service configuration files. :param service: The service's name :param namespace: The namespace for that service to check instance_type_class: The type of the instance, op...
get_expected_instance_count_for_namespace
python
Yelp/paasta
paasta_tools/long_running_service_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/long_running_service_tools.py
Apache-2.0
def reserve_unique_mac_address(lock_directory): """Pick and reserve a unique mac address for a container returns (mac_address, lockfile) where the mac address is a string in the form of 00:00:00:00:00:00 and lockfile is a file object that holds an exclusive lock """ for x in range(100): ...
Pick and reserve a unique mac address for a container returns (mac_address, lockfile) where the mac address is a string in the form of 00:00:00:00:00:00 and lockfile is a file object that holds an exclusive lock
reserve_unique_mac_address
python
Yelp/paasta
paasta_tools/mac_address.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mac_address.py
Apache-2.0
def obtain_lock(lock_filepath): """Open and obtain a flock on the parameter. Returns a file if successful, None if not""" lock_file = open(lock_filepath, "w") try: fcntl.flock(lock_file, fcntl.LOCK_EX | fcntl.LOCK_NB) return lock_file except IOError as err: if err.errno != errno....
Open and obtain a flock on the parameter. Returns a file if successful, None if not
obtain_lock
python
Yelp/paasta
paasta_tools/mac_address.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mac_address.py
Apache-2.0
def base_api(mesos_config_path: Optional[str] = None): """Helper function for making all API requests :returns: a function that can be called to make a request """ leader = get_mesos_leader(mesos_config_path) def execute_request(method, endpoint, timeout=(3, 2), **kwargs): url = "http://%s...
Helper function for making all API requests :returns: a function that can be called to make a request
base_api
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def master_api(mesos_config_path: Optional[str] = None): """Helper function for making API requests to the /master API endpoints :returns: a function that can be called to make a request to /master """ def execute_master_api_request(method, endpoint, **kwargs): base_api_client = base_api(mesos...
Helper function for making API requests to the /master API endpoints :returns: a function that can be called to make a request to /master
master_api
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def reserve_api(): """Helper function for making API requests to the /reserve API endpoints :returns: a function that can be called to make a request to /reserve """ def execute_reserve_api_request(method, endpoint, **kwargs): master_api_client = master_api() return master_api_client(m...
Helper function for making API requests to the /reserve API endpoints :returns: a function that can be called to make a request to /reserve
reserve_api
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def unreserve_api(): """Helper function for making API requests to the /unreserve API endpoints :returns: a function that can be called to make a request to /unreserve """ def execute_unreserve_api_request(method, endpoint, **kwargs): master_api_client = master_api() return master_api_...
Helper function for making API requests to the /unreserve API endpoints :returns: a function that can be called to make a request to /unreserve
unreserve_api
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def maintenance_api(): """Helper function for making API requests to the /master/maintenance API endpoints :returns: a function that can be called to make a request to /master/maintenance """ def execute_schedule_api_request(method, endpoint, **kwargs): master_api_client = master_api() ...
Helper function for making API requests to the /master/maintenance API endpoints :returns: a function that can be called to make a request to /master/maintenance
maintenance_api
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_schedule_client(): """Helper function for making API requests to the /master/maintenance/schedule API endpoints :returns: a function that can be called to make a request to /master/maintenance/schedule """ def execute_schedule_api_request(method, endpoint, **kwargs): maintenance_api_cl...
Helper function for making API requests to the /master/maintenance/schedule API endpoints :returns: a function that can be called to make a request to /master/maintenance/schedule
get_schedule_client
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_maintenance_schedule(): """Makes a GET_MAINTENANCE_SCHEDULE request to the operator api :returns: a GET_MAINTENANCE_SCHEDULE response """ client_fn = operator_api() return client_fn(data={"type": "GET_MAINTENANCE_SCHEDULE"})
Makes a GET_MAINTENANCE_SCHEDULE request to the operator api :returns: a GET_MAINTENANCE_SCHEDULE response
get_maintenance_schedule
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_maintenance_status(mesos_config_path: Optional[str] = None): """Makes a GET_MAINTENANCE_STATUS request to the operator api :returns: a GET_MAINTENANCE_STATUS response """ client_fn = operator_api(mesos_config_path=mesos_config_path) return client_fn(data={"type": "GET_MAINTENANCE_STATUS"})
Makes a GET_MAINTENANCE_STATUS request to the operator api :returns: a GET_MAINTENANCE_STATUS response
get_maintenance_status
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def schedule(): """Get the Mesos maintenance schedule. This contains hostname/ip mappings and their maintenance window. :returns: GET_MAINTENANCE_SCHEDULE response text """ try: schedule = get_maintenance_schedule() except HTTPError: raise HTTPError("Error getting maintenance schedul...
Get the Mesos maintenance schedule. This contains hostname/ip mappings and their maintenance window. :returns: GET_MAINTENANCE_SCHEDULE response text
schedule
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_hosts_with_state( state, system_paasta_config: Optional[SystemPaastaConfig] = None ) -> List[str]: """Helper function to check the maintenance status and return all hosts listed as being in a current state :param state: State we are interested in ('down_machines' or 'draining_machines') :re...
Helper function to check the maintenance status and return all hosts listed as being in a current state :param state: State we are interested in ('down_machines' or 'draining_machines') :returns: A list of hostnames in the specified state or an empty list if no machines
get_hosts_with_state
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_draining_hosts(system_paasta_config: Optional[SystemPaastaConfig] = None): """Returns a list of hostnames that are marked as draining :returns: a list of strings representing hostnames """ return get_hosts_with_state( state="draining_machines", system_paasta_config=system_paasta_config ...
Returns a list of hostnames that are marked as draining :returns: a list of strings representing hostnames
get_draining_hosts
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_hosts_forgotten_draining(grace=0): """Find hosts that are still marked as draining (rather than down) after the start of their maintenance window. :param grace: integer number of nanoseconds to allow a host to be left in the draining state after the start of its maintenance window before we cons...
Find hosts that are still marked as draining (rather than down) after the start of their maintenance window. :param grace: integer number of nanoseconds to allow a host to be left in the draining state after the start of its maintenance window before we consider it forgotten. :returns: a list of hostnam...
get_hosts_forgotten_draining
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_hosts_forgotten_down(grace=0): """Find hosts that are still marked as down (rather than up) after the end of their maintenance window. :param grace: integer number of nanoseconds to allow a host to be left in the down state after the end of its maintenance window before we consider it forgotten....
Find hosts that are still marked as down (rather than up) after the end of their maintenance window. :param grace: integer number of nanoseconds to allow a host to be left in the down state after the end of its maintenance window before we consider it forgotten. :returns: a list of hostnames of hosts fo...
get_hosts_forgotten_down
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def parse_timedelta(value): """Return the delta in nanoseconds. :param value: a string containing a time format supported by :mod:`pytimeparse` :returns: an integer (or float) representing the specified delta in nanoseconds """ error_msg = "'%s' is not a valid time expression" % value try: ...
Return the delta in nanoseconds. :param value: a string containing a time format supported by :mod:`pytimeparse` :returns: an integer (or float) representing the specified delta in nanoseconds
parse_timedelta
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def parse_datetime(value): """Return the datetime in nanoseconds. :param value: a string containing a datetime supported by :mod:`dateutil.parser` :returns: an integer (or float) representing the specified datetime in nanoseconds """ error_msg = "'%s' is not a valid datetime expression" % value ...
Return the datetime in nanoseconds. :param value: a string containing a datetime supported by :mod:`dateutil.parser` :returns: an integer (or float) representing the specified datetime in nanoseconds
parse_datetime
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def build_maintenance_payload(hostnames, maint_type): """Creates the JSON payload necessary to bring the specified hostnames up/down for maintenance. :param hostnames: a list of hostnames :returns: a dictionary representing the list of machines to bring up/down for maintenance """ return { "...
Creates the JSON payload necessary to bring the specified hostnames up/down for maintenance. :param hostnames: a list of hostnames :returns: a dictionary representing the list of machines to bring up/down for maintenance
build_maintenance_payload
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def hostnames_to_components(hostnames, resolve=False): """Converts a list of 'host[|ip]' entries into namedtuples containing 'host' and 'ip' attributes, optionally performing a DNS lookup to resolve the hostname into an IP address :param hostnames: a list of hostnames where each hostname can be of the form ...
Converts a list of 'host[|ip]' entries into namedtuples containing 'host' and 'ip' attributes, optionally performing a DNS lookup to resolve the hostname into an IP address :param hostnames: a list of hostnames where each hostname can be of the form 'host[|ip]' :param resolve: boolean representing whether t...
hostnames_to_components
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_machine_ids(hostnames): """Helper function to convert a list of hostnames into a JSON list of hostname/ip pairs. :param hostnames: a list of hostnames :returns: a dictionary representing the list of machines to bring up/down for maintenance """ machine_ids = [] components = hostnames_to_...
Helper function to convert a list of hostnames into a JSON list of hostname/ip pairs. :param hostnames: a list of hostnames :returns: a dictionary representing the list of machines to bring up/down for maintenance
get_machine_ids
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def build_reservation_payload(resources): """Creates the JSON payload needed to dynamically (un)reserve resources in mesos. :param resources: list of Resource named tuples specifying the name and amount of the resource to (un)reserve :returns: a dictionary that can be sent to Mesos to (un)reserve resources ...
Creates the JSON payload needed to dynamically (un)reserve resources in mesos. :param resources: list of Resource named tuples specifying the name and amount of the resource to (un)reserve :returns: a dictionary that can be sent to Mesos to (un)reserve resources
build_reservation_payload
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def build_maintenance_schedule_payload( hostnames, start=None, duration=None, drain=True ): """Creates the JSON payload needed to (un)schedule maintenance on the specified hostnames. :param hostnames: a list of hostnames :param start: the time to start the maintenance, represented as number of nanosecon...
Creates the JSON payload needed to (un)schedule maintenance on the specified hostnames. :param hostnames: a list of hostnames :param start: the time to start the maintenance, represented as number of nanoseconds since the epoch :param duration: length of the maintenance window, represented as number of nano...
build_maintenance_schedule_payload
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def load_credentials(mesos_secrets="/nail/etc/mesos-slave-secret"): """Loads the mesos-slave credentials from the specified file. These credentials will be used for all maintenance API requests. :param mesos_secrets: optional argument specifying the path to the file containing the mesos-slave credentials ...
Loads the mesos-slave credentials from the specified file. These credentials will be used for all maintenance API requests. :param mesos_secrets: optional argument specifying the path to the file containing the mesos-slave credentials :returns: a tuple of the form (username, password)
load_credentials
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def reserve(slave_id, resources): """Dynamically reserve resources in mesos to prevent tasks from using them. :param slave_id: the id of the mesos slave :param resources: list of Resource named tuples specifying the name and amount of the resource to (un)reserve :returns: boolean where 0 represents succ...
Dynamically reserve resources in mesos to prevent tasks from using them. :param slave_id: the id of the mesos slave :param resources: list of Resource named tuples specifying the name and amount of the resource to (un)reserve :returns: boolean where 0 represents success and 1 is a failure
reserve
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def unreserve(slave_id, resources): """Dynamically unreserve resources in mesos to allow tasks to using them. :param slave_id: the id of the mesos slave :param resources: list of Resource named tuples specifying the name and amount of the resource to (un)reserve :returns: boolean where 0 represents succ...
Dynamically unreserve resources in mesos to allow tasks to using them. :param slave_id: the id of the mesos slave :param resources: list of Resource named tuples specifying the name and amount of the resource to (un)reserve :returns: boolean where 0 represents success and 1 is a failure
unreserve
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def components_to_hosts(components): """Convert a list of Component namedtuples to a list of their hosts :param components: a list of Component namedtuples :returns: list of the hosts associated with each Component """ hosts = [] for component in components: hosts.append(component.host) ...
Convert a list of Component namedtuples to a list of their hosts :param components: a list of Component namedtuples :returns: list of the hosts associated with each Component
components_to_hosts
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def reserve_all_resources(hostnames): """Dynamically reserve all available resources on the specified hosts :param hostnames: list of hostnames to reserve resources on """ mesos_state = a_sync.block(get_mesos_master().state_summary) components = hostnames_to_components(hostnames) hosts = compone...
Dynamically reserve all available resources on the specified hosts :param hostnames: list of hostnames to reserve resources on
reserve_all_resources
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def unreserve_all_resources(hostnames): """Dynamically unreserve all available resources on the specified hosts :param hostnames: list of hostnames to unreserve resources on """ mesos_state = a_sync.block(get_mesos_master().state_summary) components = hostnames_to_components(hostnames) hosts = c...
Dynamically unreserve all available resources on the specified hosts :param hostnames: list of hostnames to unreserve resources on
unreserve_all_resources
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def drain(hostnames, start, duration, reserve_resources=True): """Schedules a maintenance window for the specified hosts and marks them as draining. :param hostnames: a list of hostnames :param start: the time to start the maintenance, represented as number of nanoseconds since the epoch :param duration...
Schedules a maintenance window for the specified hosts and marks them as draining. :param hostnames: a list of hostnames :param start: the time to start the maintenance, represented as number of nanoseconds since the epoch :param duration: length of the maintenance window, represented as number of nanosecon...
drain
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def undrain(hostnames, unreserve_resources=True): """Unschedules the maintenance window for the specified hosts and unmarks them as draining. They are ready for regular use. :param hostnames: a list of hostnames :param unreserve_resources: bool setting to also unreserve resources on the agent before the...
Unschedules the maintenance window for the specified hosts and unmarks them as draining. They are ready for regular use. :param hostnames: a list of hostnames :param unreserve_resources: bool setting to also unreserve resources on the agent before the undrain call :returns: None
undrain
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def down(hostnames): """Marks the specified hostnames as being down for maintenance, and makes them unavailable for use. :param hostnames: a list of hostnames :returns: None """ log.info("Bringing down: %s" % hostnames) payload = build_maintenance_payload(hostnames, "start_maintenance") clie...
Marks the specified hostnames as being down for maintenance, and makes them unavailable for use. :param hostnames: a list of hostnames :returns: None
down
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def up(hostnames): """Marks the specified hostnames as no longer being down for maintenance, and makes them available for use. :param hostnames: a list of hostnames :returns: None """ log.info("Bringing up: %s" % hostnames) payload = build_maintenance_payload(hostnames, "stop_maintenance") c...
Marks the specified hostnames as no longer being down for maintenance, and makes them available for use. :param hostnames: a list of hostnames :returns: None
up
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def raw_status(): """Get the Mesos maintenance status. This contains hostname/ip mappings for hosts that are either marked as being down for maintenance or draining. :returns: Response Object containing status """ try: status = get_maintenance_status() except HTTPError: raise HTT...
Get the Mesos maintenance status. This contains hostname/ip mappings for hosts that are either marked as being down for maintenance or draining. :returns: Response Object containing status
raw_status
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def friendly_status(): """Display the Mesos maintenance status in a human-friendly way. :returns: Text representation of the human-friendly status """ status = raw_status().json()["get_maintenance_status"]["status"] ret = "" for machine in status.get("draining_machines", []): ret += "{} ...
Display the Mesos maintenance status in a human-friendly way. :returns: Text representation of the human-friendly status
friendly_status
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def is_host_drained(hostname): """Checks if a host has drained successfully by confirming it is draining and currently running 0 tasks :param hostname: hostname to check :returns: True or False """ return ( is_host_draining(hostname=hostname) and get_count_running_tasks_on_slave(...
Checks if a host has drained successfully by confirming it is draining and currently running 0 tasks :param hostname: hostname to check :returns: True or False
is_host_drained
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_hosts_past_maintenance_start(grace=0): """Get a list of hosts that have reached the start of their maintenance window :param grace: integer number of nanoseconds to allow a host to be left in the draining state after the start of its maintenance window before we consider it past its maintenance star...
Get a list of hosts that have reached the start of their maintenance window :param grace: integer number of nanoseconds to allow a host to be left in the draining state after the start of its maintenance window before we consider it past its maintenance start :returns: List of hostnames
get_hosts_past_maintenance_start
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_hosts_past_maintenance_end(grace=0): """Get a list of hosts that have reached the end of their maintenance window :param grace: integer number of nanoseconds to allow a host to be left in the down state after the end of its maintenance window before we consider it past its maintenance end :retur...
Get a list of hosts that have reached the end of their maintenance window :param grace: integer number of nanoseconds to allow a host to be left in the down state after the end of its maintenance window before we consider it past its maintenance end :returns: List of hostnames
get_hosts_past_maintenance_end
python
Yelp/paasta
paasta_tools/mesos_maintenance.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_maintenance.py
Apache-2.0
def get_mesos_config_path( system_paasta_config: Optional[SystemPaastaConfig] = None, ) -> str: """ Determine where to find the configuration for mesos-cli. """ if system_paasta_config is None: system_paasta_config = load_system_paasta_config() return system_paasta_config.get_mesos_cli_...
Determine where to find the configuration for mesos-cli.
get_mesos_config_path
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_mesos_leader(mesos_config_path: Optional[str] = None) -> str: """Get the current mesos-master leader's hostname. Attempts to determine this by using mesos.cli to query ZooKeeper. :returns: The current mesos-master hostname""" try: url = get_mesos_master(mesos_config_path).host excep...
Get the current mesos-master leader's hostname. Attempts to determine this by using mesos.cli to query ZooKeeper. :returns: The current mesos-master hostname
get_mesos_leader
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def find_mesos_leader(cluster): """Find the leader with redirect given one mesos master.""" master = ( load_system_paasta_config().get_cluster_fqdn_format().format(cluster=cluster) ) if master is None: raise ValueError("Mesos master is required to find leader") url = f"http://{maste...
Find the leader with redirect given one mesos master.
find_mesos_leader
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_current_tasks(job_id: str) -> List[Task]: """Returns a list of all the tasks with a given job id. :param job_id: the job id of the tasks. :return tasks: a list of mesos.cli.Task. """ mesos_master = get_mesos_master() framework_tasks = await mesos_master.tasks(fltr=job_id, active_on...
Returns a list of all the tasks with a given job id. :param job_id: the job id of the tasks. :return tasks: a list of mesos.cli.Task.
get_current_tasks
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_running_tasks_from_frameworks(job_id=""): """Will include tasks from active and completed frameworks but NOT orphaned tasks """ active_framework_tasks = await get_current_tasks(job_id) running_tasks = filter_running_tasks(active_framework_tasks) return running_tasks
Will include tasks from active and completed frameworks but NOT orphaned tasks
get_running_tasks_from_frameworks
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_all_running_tasks() -> Collection[Task]: """Will include all running tasks; for now orphans are not included""" framework_tasks = await get_current_tasks("") mesos_master = get_mesos_master() framework_tasks += await mesos_master.orphan_tasks() running_tasks = filter_running_tasks(fram...
Will include all running tasks; for now orphans are not included
get_all_running_tasks
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_cached_list_of_all_current_tasks(): """Returns a cached list of all mesos tasks. This function is used by 'paasta status' and 'paasta_serviceinit status' to avoid re-querying mesos master and re-parsing json to get mesos.Task objects. The async_ttl_cache decorator caches the list for 60...
Returns a cached list of all mesos tasks. This function is used by 'paasta status' and 'paasta_serviceinit status' to avoid re-querying mesos master and re-parsing json to get mesos.Task objects. The async_ttl_cache decorator caches the list for 600 seconds. ttl doesn't really matter for this functio...
get_cached_list_of_all_current_tasks
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_cached_list_of_running_tasks_from_frameworks(): """Returns a cached list of all running mesos tasks. See the docstring for get_cached_list_of_all_current_tasks(). :return tasks: a list of mesos.Task """ return [ task for task in filter_running_tasks(await get_cached_li...
Returns a cached list of all running mesos tasks. See the docstring for get_cached_list_of_all_current_tasks(). :return tasks: a list of mesos.Task
get_cached_list_of_running_tasks_from_frameworks
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_cached_list_of_not_running_tasks_from_frameworks(): """Returns a cached list of mesos tasks that are NOT running. See the docstring for get_cached_list_of_all_current_tasks(). :return tasks: a list of mesos.Task""" return [ task for task in filter_not_running_tasks( ...
Returns a cached list of mesos tasks that are NOT running. See the docstring for get_cached_list_of_all_current_tasks(). :return tasks: a list of mesos.Task
get_cached_list_of_not_running_tasks_from_frameworks
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_first_status_timestamp_string(task: Task) -> str: """Gets the first status timestamp from a task id and returns a human readable string with the local time and a humanized duration: ``2015-01-30T08:45 (an hour ago)`` """ first_status_timestamp = get_first_status_timestamp(task) if first_...
Gets the first status timestamp from a task id and returns a human readable string with the local time and a humanized duration: ``2015-01-30T08:45 (an hour ago)``
get_first_status_timestamp_string
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_cpu_usage(task: Task) -> str: """Calculates a metric of used_cpu/allocated_cpu To do this, we take the total number of cpu-seconds the task has consumed, (the sum of system and user time), OVER the total cpu time the task has been allocated. The total time a task has been allocated is...
Calculates a metric of used_cpu/allocated_cpu To do this, we take the total number of cpu-seconds the task has consumed, (the sum of system and user time), OVER the total cpu time the task has been allocated. The total time a task has been allocated is the total time the task has been running (http...
get_cpu_usage
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def format_running_mesos_task_row( task: Task, get_short_task_id: Callable[[str], str] ) -> Tuple[str, ...]: """Returns a pretty formatted string of a running mesos task attributes""" short_task_id = get_short_task_id(task["id"]) short_hostname_future = asyncio.ensure_future( results_or_u...
Returns a pretty formatted string of a running mesos task attributes
format_running_mesos_task_row
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def zip_tasks_verbose_output(table, stdstreams): """Zip a list of strings (table) with a list of lists (stdstreams) :param table: a formatted list of tasks :param stdstreams: for each task, a list of lines from stdout/stderr tail """ if len(table) != len(stdstreams): raise ValueError("Can on...
Zip a list of strings (table) with a list of lists (stdstreams) :param table: a formatted list of tasks :param stdstreams: for each task, a list of lines from stdout/stderr tail
zip_tasks_verbose_output
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def format_task_list( tasks: Sequence[Task], list_title: str, table_header: Sequence[str], get_short_task_id: Callable[[str], str], format_task_row: Callable[ [Task, Callable[[str], str]], Awaitable[Union[Sequence[str], str]] ], grey: bool, tail_lines: int, ) -> List[str]: ...
Formats a list of tasks, returns a list of output lines :param tasks: List of tasks as returned by get_*_tasks_from_all_frameworks. :param list_title: 'Running Tasks:' or 'Non-Running Tasks'. :param table_header: List of column names used in the tasks table. :param get_short_task_id: A function which gi...
format_task_list
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def status_mesos_tasks_verbose( filter_string: str, get_short_task_id: Callable[[str], str], tail_lines: int = 0 ) -> str: """Returns detailed information about the mesos tasks for a service. :param filter_string: An id used for looking up Mesos tasks :param get_short_task_id: A function which gi...
Returns detailed information about the mesos tasks for a service. :param filter_string: An id used for looking up Mesos tasks :param get_short_task_id: A function which given a task_id returns a short task_id suitable for printing. :param tail_lin...
status_mesos_tasks_verbose
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_local_slave_state(hostname=None): """Fetches mesos slave state and returns it as a dict. :param hostname: The host from which to fetch slave state. If not specified, defaults to the local machine.""" if hostname is None: hostname = socket.getfqdn() stats_uri = f"http://{hostname}:{MESOS...
Fetches mesos slave state and returns it as a dict. :param hostname: The host from which to fetch slave state. If not specified, defaults to the local machine.
get_local_slave_state
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_all_tasks_from_state( mesos_state: MesosState, include_orphans: bool = False ) -> Sequence[MesosTask]: """Given a mesos state, find the tasks from all frameworks. :param mesos_state: the mesos_state :returns: a list of tasks """ tasks = [ task for framework in mesos_state...
Given a mesos state, find the tasks from all frameworks. :param mesos_state: the mesos_state :returns: a list of tasks
get_all_tasks_from_state
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_zookeeper_config(state): """Returns dict, containing the zookeeper hosts and path. :param state: mesos state dictionary""" re_zk = re.match(r"^zk://([^/]*)/(.*)$", state["flags"]["zk"]) return {"hosts": re_zk.group(1), "path": re_zk.group(2)}
Returns dict, containing the zookeeper hosts and path. :param state: mesos state dictionary
get_zookeeper_config
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_number_of_mesos_masters(host, path): """Returns an array, containing mesos masters :param zk_config: dict containing information about zookeeper config. Masters register themselves in zookeeper by creating ``info_`` entries. We count these entries to get the number of masters. """ zk = K...
Returns an array, containing mesos masters :param zk_config: dict containing information about zookeeper config. Masters register themselves in zookeeper by creating ``info_`` entries. We count these entries to get the number of masters.
get_number_of_mesos_masters
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_all_slaves_for_blacklist_whitelist( blacklist: DeployBlacklist, whitelist: DeployWhitelist ): """ A wrapper function to get all slaves and filter according to provided blacklist and whitelist. :param blacklist: a blacklist, used to filter mesos slaves by attribute :param whitelist: a wh...
A wrapper function to get all slaves and filter according to provided blacklist and whitelist. :param blacklist: a blacklist, used to filter mesos slaves by attribute :param whitelist: a whitelist, used to filter mesos slaves by attribute :returns: a list of mesos slave objects, filtered by those...
get_all_slaves_for_blacklist_whitelist
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_mesos_slaves_grouped_by_attribute(slaves, attribute): """Returns a dictionary of unique values and the corresponding hosts for a given Mesos attribute :param slaves: a list of mesos slaves to group :param attribute: an attribute to filter :returns: a dictionary of the form {'<attribute_value>':...
Returns a dictionary of unique values and the corresponding hosts for a given Mesos attribute :param slaves: a list of mesos slaves to group :param attribute: an attribute to filter :returns: a dictionary of the form {'<attribute_value>': [<list of hosts with attribute=attribute_value>]} (res...
get_mesos_slaves_grouped_by_attribute
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def filter_mesos_slaves_by_blacklist( slaves, blacklist: DeployBlacklist, whitelist: DeployWhitelist ): """Takes an input list of slaves and filters them based on the given blacklist. The blacklist is in the form of: [["location_type", "location]] Where the list inside is something like ["regi...
Takes an input list of slaves and filters them based on the given blacklist. The blacklist is in the form of: [["location_type", "location]] Where the list inside is something like ["region", "uswest1-prod"] :returns: The list of mesos slaves after the filter
filter_mesos_slaves_by_blacklist
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
async def get_mesos_task_count_by_slave( mesos_state: MesosState, slaves_list: Sequence[Dict] = None, pool: Optional[str] = None, ) -> List[Dict]: """Get counts of running tasks per mesos slave. :param mesos_state: mesos state dict :param slaves_list: a list of slave dicts to count running task...
Get counts of running tasks per mesos slave. :param mesos_state: mesos state dict :param slaves_list: a list of slave dicts to count running tasks for. :param pool: pool of slaves to return (None means all) :returns: list of slave dicts {'task_count': SlaveTaskCount}
get_mesos_task_count_by_slave
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_count_running_tasks_on_slave(hostname: str) -> int: """Return the number of tasks running on a particular slave or 0 if the slave is not found. :param hostname: hostname of the slave :returns: integer count of mesos tasks""" mesos_state = a_sync.block(get_mesos_master().state_summary) ta...
Return the number of tasks running on a particular slave or 0 if the slave is not found. :param hostname: hostname of the slave :returns: integer count of mesos tasks
get_count_running_tasks_on_slave
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def mesos_services_running_here( framework_filter, parse_service_instance_from_executor_id, hostname=None ): """See what paasta_native services are being run by a mesos-slave on this host. :param framework_filter: a function that returns true if we should consider a given framework. :param parse_servic...
See what paasta_native services are being run by a mesos-slave on this host. :param framework_filter: a function that returns true if we should consider a given framework. :param parse_service_instance_from_executor_id: A function that returns a tuple of (service, instance) from the ...
mesos_services_running_here
python
Yelp/paasta
paasta_tools/mesos_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos_tools.py
Apache-2.0
def get_sensu_team_data(team): """Takes a team and returns the dictionary of Sensu configuration settings for that team. The data is in this format: https://github.com/Yelp/sensu_handlers#teams Returns an empty dictionary if there is nothing to return. Not all teams specify all the different types ...
Takes a team and returns the dictionary of Sensu configuration settings for that team. The data is in this format: https://github.com/Yelp/sensu_handlers#teams Returns an empty dictionary if there is nothing to return. Not all teams specify all the different types of configuration settings. for exa...
get_sensu_team_data
python
Yelp/paasta
paasta_tools/monitoring_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/monitoring_tools.py
Apache-2.0
def read_monitoring_config(service, soa_dir=DEFAULT_SOA_DIR): """Read a service's monitoring.yaml file. :param service: The service name :param soa_dir: THe SOA configuration directory to read from :returns: A dictionary of whatever was in soa_dir/name/monitoring.yaml""" rootdir = os.path.abspath(s...
Read a service's monitoring.yaml file. :param service: The service name :param soa_dir: THe SOA configuration directory to read from :returns: A dictionary of whatever was in soa_dir/name/monitoring.yaml
read_monitoring_config
python
Yelp/paasta
paasta_tools/monitoring_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/monitoring_tools.py
Apache-2.0
def list_teams(): """Loads team data from the system. Returns a set of team names (or empty set). """ team_data = _load_sensu_team_data() teams = set(team_data.get("team_data", {}).keys()) return teams
Loads team data from the system. Returns a set of team names (or empty set).
list_teams
python
Yelp/paasta
paasta_tools/monitoring_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/monitoring_tools.py
Apache-2.0
def check_under_replication( instance_config: LongRunningServiceConfig, expected_count: int, num_available: int, sub_component: Optional[str] = None, ) -> Tuple[bool, str, str]: """Check if a component/sub_component is under-replicated and returns both the result of the check in the form of a bo...
Check if a component/sub_component is under-replicated and returns both the result of the check in the form of a boolean and a human-readable text to be used in logging or monitoring events.
check_under_replication
python
Yelp/paasta
paasta_tools/monitoring_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/monitoring_tools.py
Apache-2.0
def load_monkrelaycluster_instance_config( service: str, instance: str, cluster: str, load_deployments: bool = True, soa_dir: str = DEFAULT_SOA_DIR, ) -> MonkRelayClusterDeploymentConfig: """Read a service instance's configuration for MonkRelayCluster. If a branch isn't specified for a conf...
Read a service instance's configuration for MonkRelayCluster. If a branch isn't specified for a config, the 'branch' key defaults to paasta-${cluster}.${instance}. :param service: The service name :param instance: The instance of the service to retrieve :param cluster: The cluster to read the conf...
load_monkrelaycluster_instance_config
python
Yelp/paasta
paasta_tools/monkrelaycluster_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/monkrelaycluster_tools.py
Apache-2.0
def load_nrtsearchserviceeks_instance_config( service: str, instance: str, cluster: str, load_deployments: bool = True, soa_dir: str = DEFAULT_SOA_DIR, ) -> NrtsearchServiceEksDeploymentConfig: """Read a service instance's configuration for Nrtsearch. If a branch isn't specified for a confi...
Read a service instance's configuration for Nrtsearch. If a branch isn't specified for a config, the 'branch' key defaults to paasta-${cluster}.${instance}. :param service: The service name :param instance: The instance of the service to retrieve :param cluster: The cluster to read the configurati...
load_nrtsearchserviceeks_instance_config
python
Yelp/paasta
paasta_tools/nrtsearchserviceeks_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/nrtsearchserviceeks_tools.py
Apache-2.0
def log_to_paasta(log_line): """Add the event to the standard PaaSTA logging backend.""" line = "oom-killer killed {} on {} (container_id: {}).".format( "a %s process" % log_line.process_name if log_line.process_name else "a process", log_line.hostname, log_line.container...
Add the event to the standard PaaSTA logging backend.
log_to_paasta
python
Yelp/paasta
paasta_tools/oom_logger.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/oom_logger.py
Apache-2.0
def clusters(self) -> Iterable[str]: """Returns an iterator that yields cluster names for the service. :returns: iterator that yields cluster names. """ if self._clusters is None: self._clusters = list_clusters(service=self._service, soa_dir=self._soa_dir) for cluste...
Returns an iterator that yields cluster names for the service. :returns: iterator that yields cluster names.
clusters
python
Yelp/paasta
paasta_tools/paasta_service_config_loader.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paasta_service_config_loader.py
Apache-2.0
def instances( self, cluster: str, instance_type_class: Type[InstanceConfig_T] ) -> Iterable[str]: """Returns an iterator that yields instance names as strings. :param cluster: The cluster name :param instance_type_class: a subclass of InstanceConfig :returns: an iterator th...
Returns an iterator that yields instance names as strings. :param cluster: The cluster name :param instance_type_class: a subclass of InstanceConfig :returns: an iterator that yields instance names
instances
python
Yelp/paasta
paasta_tools/paasta_service_config_loader.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paasta_service_config_loader.py
Apache-2.0
def instance_configs( self, cluster: str, instance_type_class: Type[InstanceConfig_T] ) -> Iterable[InstanceConfig_T]: """Returns an iterator that yields InstanceConfig objects. :param cluster: The cluster name :param instance_type_class: a subclass of InstanceConfig :return...
Returns an iterator that yields InstanceConfig objects. :param cluster: The cluster name :param instance_type_class: a subclass of InstanceConfig :returns: an iterator that yields instances of KubernetesDeploymentConfig, etc. :raises NotImplementedError: when it doesn't know how to crea...
instance_configs
python
Yelp/paasta
paasta_tools/paasta_service_config_loader.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paasta_service_config_loader.py
Apache-2.0
def _create_service_config( self, cluster: str, instance: str, config: utils.InstanceConfigDict, config_class: Type[InstanceConfig_T], ) -> InstanceConfig_T: """Create a service instance's configuration for kubernetes. :param cluster: The cluster to read the ...
Create a service instance's configuration for kubernetes. :param cluster: The cluster to read the configuration for :param instance: The instance of the service to retrieve :param config: the framework instance config. :returns: An instance of config_class
_create_service_config
python
Yelp/paasta
paasta_tools/paasta_service_config_loader.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paasta_service_config_loader.py
Apache-2.0
def _make_determine_wants_func(ref_mutator): """Returns a safer version of ref_mutator, suitable for passing as the determine_wants argument to dulwich's send_pack method. The returned function will not delete or modify any existing refs.""" def determine_wants(old_refs): refs = {k.decode("UTF-...
Returns a safer version of ref_mutator, suitable for passing as the determine_wants argument to dulwich's send_pack method. The returned function will not delete or modify any existing refs.
_make_determine_wants_func
python
Yelp/paasta
paasta_tools/remote_git.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/remote_git.py
Apache-2.0
def make_force_push_mutate_refs_func(targets, sha): """Create a 'force push' function that will inform send_pack that we want to mark a certain list of target branches/tags to point to a particular git_sha. :param targets: List of branches/tags to point at the input sha :param sha: The git sha to p...
Create a 'force push' function that will inform send_pack that we want to mark a certain list of target branches/tags to point to a particular git_sha. :param targets: List of branches/tags to point at the input sha :param sha: The git sha to point the branches/tags at :returns: A function to do th...
make_force_push_mutate_refs_func
python
Yelp/paasta
paasta_tools/remote_git.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/remote_git.py
Apache-2.0
def create_remote_refs(git_url, ref_mutator, force=False): """Creates refs (tags, branches) on a remote git repo. :param git_url: the URL or path to the remote git repo. :param ref_mutator: A function that determines the new refs to create on the remote repo. This gets passed a dict...
Creates refs (tags, branches) on a remote git repo. :param git_url: the URL or path to the remote git repo. :param ref_mutator: A function that determines the new refs to create on the remote repo. This gets passed a dictionary of the remote server's refs in the ...
create_remote_refs
python
Yelp/paasta
paasta_tools/remote_git.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/remote_git.py
Apache-2.0
def list_remote_refs(git_url): """Get the refs from a remote git repo as a dictionary of name->hash.""" client, path = dulwich.client.get_transport_and_path(git_url) try: refs = client.fetch_pack(path, lambda refs: [], None, lambda data: None) return {k.decode("UTF-8"): v.decode("UTF-8") for...
Get the refs from a remote git repo as a dictionary of name->hash.
list_remote_refs
python
Yelp/paasta
paasta_tools/remote_git.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/remote_git.py
Apache-2.0
def get_authors(git_url, from_sha, to_sha): """Gets the list of authors who contributed to a git changeset. Currently only supports fetching this in a very "yelpy" way by executing a gitolite command""" matches = re.match("(?P<git_server>.*):(?P<git_repo>.*)", git_url) if matches is None: re...
Gets the list of authors who contributed to a git changeset. Currently only supports fetching this in a very "yelpy" way by executing a gitolite command
get_authors
python
Yelp/paasta
paasta_tools/remote_git.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/remote_git.py
Apache-2.0
def is_shared_secret_from_secret_name(soa_dir: str, secret_name: str) -> bool: """Alternative way of figuring if a secret is shared, directly from the secret_name.""" secret_path = os.path.join( soa_dir, SHARED_SECRET_SERVICE, "secrets", f"{secret_name}.json" ) return os.path.isfile(secret_path)
Alternative way of figuring if a secret is shared, directly from the secret_name.
is_shared_secret_from_secret_name
python
Yelp/paasta
paasta_tools/secret_tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/secret_tools.py
Apache-2.0
def get_hpa_overrides(kube_client: KubeClient) -> Dict[str, Dict[str, HpaOverride]]: """ Load autoscaling overrides from the ConfigMap once. This function reads the "paasta-autoscaling-overrides" ConfigMap in the "paasta" namespace and extracts all valid (non-expired) overrides to return a dictionary m...
Load autoscaling overrides from the ConfigMap once. This function reads the "paasta-autoscaling-overrides" ConfigMap in the "paasta" namespace and extracts all valid (non-expired) overrides to return a dictionary mapping service.instance pairs to override data (currently, just min_instances and when t...
get_hpa_overrides
python
Yelp/paasta
paasta_tools/setup_kubernetes_job.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/setup_kubernetes_job.py
Apache-2.0
def _minify_promql(query: str) -> str: """ Given a PromQL query, return the same query with most whitespace collapsed. This is useful for allowing us to nicely format queries in code, but minimize the size of our queries when they're actually sent to Prometheus by the adapter. """ trimmed_query...
Given a PromQL query, return the same query with most whitespace collapsed. This is useful for allowing us to nicely format queries in code, but minimize the size of our queries when they're actually sent to Prometheus by the adapter.
_minify_promql
python
Yelp/paasta
paasta_tools/setup_prometheus_adapter_config.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/setup_prometheus_adapter_config.py
Apache-2.0
def create_instance_active_requests_scaling_rule( service: str, instance_config: KubernetesDeploymentConfig, metrics_provider_config: MetricsProviderDict, paasta_cluster: str, ) -> PrometheusAdapterRule: """ Creates a Prometheus adapter rule config for a given service instance. """ insta...
Creates a Prometheus adapter rule config for a given service instance.
create_instance_active_requests_scaling_rule
python
Yelp/paasta
paasta_tools/setup_prometheus_adapter_config.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/setup_prometheus_adapter_config.py
Apache-2.0
def get_rules_for_service_instance( service_name: str, instance_config: KubernetesDeploymentConfig, paasta_cluster: str, ) -> List[PrometheusAdapterRule]: """ Returns a list of Prometheus Adapter rules for a given service instance. For now, this will always be a 0 or 1-element list - but when we...
Returns a list of Prometheus Adapter rules for a given service instance. For now, this will always be a 0 or 1-element list - but when we support scaling on multiple metrics we will return N rules for a given service instance.
get_rules_for_service_instance
python
Yelp/paasta
paasta_tools/setup_prometheus_adapter_config.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/setup_prometheus_adapter_config.py
Apache-2.0