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 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 |
async def get_non_running_tasks_from_frameworks(job_id: str = "") -> List[Task]:
"""Will include tasks from active and completed frameworks
but NOT orphaned tasks
"""
active_framework_tasks = await get_current_tasks(job_id)
not_running_tasks = filter_not_running_tasks(active_framework_tasks)
ret... | Will include tasks from active and completed frameworks
but NOT orphaned tasks
| get_non_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 |
async def format_non_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"""
return (
PaastaColors.grey(get_short_task_id(task["id"])),
PaastaColors.grey(await results_or_unkn... | Returns a pretty formatted string of a running mesos task attributes | format_non_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 load_nrtsearchservice_instance_config(
service: str,
instance: str,
cluster: str,
load_deployments: bool = True,
soa_dir: str = DEFAULT_SOA_DIR,
) -> NrtsearchServiceDeploymentConfig:
"""Read a service instance's configuration for Nrtsearch.
If a branch isn't specified for a config, the... | 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_nrtsearchservice_instance_config | python | Yelp/paasta | paasta_tools/nrtsearchservice_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/nrtsearchservice_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 create_instance_uwsgi_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.
"""
instance = inst... |
Creates a Prometheus adapter rule config for a given service instance.
| create_instance_uwsgi_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 create_instance_uwsgi_v2_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.
"""
instance = i... |
Creates a Prometheus adapter rule config for a given service instance.
| create_instance_uwsgi_v2_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 create_instance_piscina_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.
"""
instance = in... |
Creates a Prometheus adapter rule config for a given service instance.
| create_instance_piscina_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 create_instance_gunicorn_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.
"""
instance = i... |
Creates a Prometheus adapter rule config for a given service instance.
| create_instance_gunicorn_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 |
def create_prometheus_adapter_config(
paasta_cluster: str, soa_dir: Path
) -> PrometheusAdapterConfig:
"""
Given a paasta cluster and a soaconfigs directory, create the necessary Prometheus adapter
config to autoscale services.
Currently supports the following metrics providers:
* uwsgi
... |
Given a paasta cluster and a soaconfigs directory, create the necessary Prometheus adapter
config to autoscale services.
Currently supports the following metrics providers:
* uwsgi
| create_prometheus_adapter_config | 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 retrieve_haproxy_csv(
synapse_host: str, synapse_port: int, synapse_haproxy_url_format: str, scope: str
) -> Iterable[Dict[str, str]]:
"""Retrieves the haproxy csv from the haproxy web interface
:param synapse_host: A host that this check should contact for replication information.
:param synapse_p... | Retrieves the haproxy csv from the haproxy web interface
:param synapse_host: A host that this check should contact for replication information.
:param synapse_port: A integer that this check should contact for replication information.
:param synapse_haproxy_url_format: The format of the synapse haproxy UR... | retrieve_haproxy_csv | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def get_backends(
service: str, synapse_host: str, synapse_port: int, synapse_haproxy_url_format: str
) -> List[HaproxyBackend]:
"""Fetches the CSV from haproxy and returns a list of backends,
regardless of their state.
:param service: If None, return backends for all services, otherwise only return ba... | Fetches the CSV from haproxy and returns a list of backends,
regardless of their state.
:param service: If None, return backends for all services, otherwise only return backends for this particular
service.
:param synapse_host: A host that this check should contact for replication infor... | get_backends | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def get_multiple_backends(
services: Optional[Collection[str]],
synapse_host: str,
synapse_port: int,
synapse_haproxy_url_format: str,
) -> List[HaproxyBackend]:
"""Fetches the CSV from haproxy and returns a list of backends,
regardless of their state.
:param services: If None, return backe... | Fetches the CSV from haproxy and returns a list of backends,
regardless of their state.
:param services: If None, return backends for all services, otherwise only return backends for these particular
services.
:param synapse_host: A host that this check should contact for replication i... | get_multiple_backends | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def load_smartstack_info_for_service(
service: str,
namespace: str,
blacklist: DeployBlacklist,
system_paasta_config: SystemPaastaConfig,
soa_dir: str = DEFAULT_SOA_DIR,
) -> Dict[str, Dict[str, int]]:
"""Retrieves number of available backends for given service
:param service: A service nam... | Retrieves number of available backends for given service
:param service: A service name
:param namespace: A Smartstack namespace
:param blacklist: A list of blacklisted location tuples in the form (location, value)
:param system_paasta_config: A SystemPaastaConfig object representing the system configu... | load_smartstack_info_for_service | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def get_smartstack_replication_for_attribute(
attribute: str,
service: str,
namespace: str,
blacklist: DeployBlacklist,
system_paasta_config: SystemPaastaConfig,
) -> Dict[str, Dict[str, int]]:
"""Loads smartstack replication from a host with the specified attribute
:param attribute: a Meso... | Loads smartstack replication from a host with the specified attribute
:param attribute: a Mesos attribute
:param service: A service name, like 'example_service'
:param namespace: A particular smartstack namespace to inspect, like 'main'
:param blacklist: A list of blacklisted location tuples in the for... | get_smartstack_replication_for_attribute | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def get_replication_for_all_services(
synapse_host: str, synapse_port: int, synapse_haproxy_url_format: str
) -> Dict[str, int]:
"""Returns the replication level for all services known to this synapse haproxy
:param synapse_host: The host that this check should contact for replication information.
:par... | Returns the replication level for all services known to this synapse haproxy
:param synapse_host: The host that this check should contact for replication information.
:param synapse_port: The port that this check should contact for replication information.
:param synapse_haproxy_url_format: The format of t... | get_replication_for_all_services | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def get_replication_for_services(
synapse_host: str,
synapse_port: int,
synapse_haproxy_url_format: str,
services: Collection[str],
) -> Dict[str, int]:
"""Returns the replication level for the provided services
This check is intended to be used with an haproxy load balancer, and
relies on ... | Returns the replication level for the provided services
This check is intended to be used with an haproxy load balancer, and
relies on the implementation details of that choice.
:param synapse_host: The host that this check should contact for replication information.
:param synapse_port: The port that... | get_replication_for_services | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def ip_port_hostname_from_svname(svname: str) -> Tuple[str, int, str]:
"""This parses the haproxy svname that smartstack creates.
In old versions of synapse, this is in the format ip:port_hostname.
In versions newer than dd5843c987740a5d5ce1c83b12b258b7253784a8 it is
hostname_ip:port
:param svname:... | This parses the haproxy svname that smartstack creates.
In old versions of synapse, this is in the format ip:port_hostname.
In versions newer than dd5843c987740a5d5ce1c83b12b258b7253784a8 it is
hostname_ip:port
:param svname: A svname, in either of the formats described above
:returns ip_port_hostn... | ip_port_hostname_from_svname | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def match_backends_and_pods(
backends: Iterable[HaproxyBackend], pods: Iterable[V1Pod]
) -> List[Tuple[Optional[HaproxyBackend], Optional[V1Pod]]]:
"""Returns tuples of matching (backend, pod) pairs, as matched by IP. Each backend will be listed exactly
once. If a backend does not match with a pod, (backend... | Returns tuples of matching (backend, pod) pairs, as matched by IP. Each backend will be listed exactly
once. If a backend does not match with a pod, (backend, None) will be included.
If a pod's IP does not match with any backends, (None, pod) will be included.
:param backends: An iterable of haproxy backen... | match_backends_and_pods | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def get_replication_for_instance(
self, instance_config: LongRunningServiceConfig
) -> Dict[str, Dict[str, Dict[str, int]]]:
"""Returns the number of registered instances in each discoverable
location for each service dicrovery provider.
:param instance_config: An instance of LongRu... | Returns the number of registered instances in each discoverable
location for each service dicrovery provider.
:param instance_config: An instance of LongRunningServiceConfig.
:returns: a dict {'service_discovery_provider': {'location_type': {'service.instance': int}}}
| get_replication_for_instance | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def _get_replication_info(
self,
location: str,
hostname: str,
instance_config: LongRunningServiceConfig,
provider: ServiceDiscoveryProvider,
) -> Dict[str, int]:
"""Returns service.instance and the number of instances registered in smartstack
at the location ... | Returns service.instance and the number of instances registered in smartstack
at the location as a dict.
:param location: A string that identifies a habitat, a region and etc.
:param hostname: A mesos slave hostname to read replication information from.
:param instance_config: An instan... | _get_replication_info | python | Yelp/paasta | paasta_tools/smartstack_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/smartstack_tools.py | Apache-2.0 |
def setup_volume_mounts(volumes: List[DockerVolume]) -> Dict[str, str]:
"""
Returns Docker volume mount configurations in the format expected by Spark.
"""
conf = {}
# XXX: why are these necessary?
extra_volumes: List[DockerVolume] = cast(
"List[DockerVolume]",
[
{"c... |
Returns Docker volume mount configurations in the format expected by Spark.
| setup_volume_mounts | python | Yelp/paasta | paasta_tools/spark_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/spark_tools.py | Apache-2.0 |
def get_spark_driver_monitoring_annotations(
spark_config: Dict[str, str],
) -> Dict[str, str]:
"""
Returns Spark driver pod annotations - currently used for Prometheus metadata.
"""
annotations: Dict[str, str] = {}
ui_port_str = spark_config.get("spark.ui.port")
if ui_port_str:
ann... |
Returns Spark driver pod annotations - currently used for Prometheus metadata.
| get_spark_driver_monitoring_annotations | python | Yelp/paasta | paasta_tools/spark_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/spark_tools.py | Apache-2.0 |
def get_spark_driver_monitoring_labels(
spark_config: Dict[str, str],
user: str,
) -> Dict[str, str]:
"""
Returns Spark driver pod labels - generally for Prometheus metric relabeling.
"""
ui_port_str = str(spark_config.get("spark.ui.port", ""))
labels = {
"paasta.yelp.com/prometheus_... |
Returns Spark driver pod labels - generally for Prometheus metric relabeling.
| get_spark_driver_monitoring_labels | python | Yelp/paasta | paasta_tools/spark_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/spark_tools.py | Apache-2.0 |
def get_cluster_name(self):
""":returns The name of the Tron cluster"""
try:
return self["cluster_name"]
except KeyError:
raise TronNotConfigured(
"Could not find name of Tron cluster in system Tron config"
) | :returns The name of the Tron cluster | get_cluster_name | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def get_url(self):
""":returns The URL for the Tron master's API"""
try:
return self["url"]
except KeyError:
raise TronNotConfigured(
"Could not find URL of Tron master in system Tron config"
) | :returns The URL for the Tron master's API | get_url | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def parse_time_variables(command: str, parse_time: datetime.datetime = None) -> str:
"""Parses an input string and uses the Tron-style dateparsing
to replace time variables. Currently supports only the date/time
variables listed in the tron documentation:
http://tron.readthedocs.io/en/latest/command_con... | Parses an input string and uses the Tron-style dateparsing
to replace time variables. Currently supports only the date/time
variables listed in the tron documentation:
http://tron.readthedocs.io/en/latest/command_context.html#built-in-cc
:param input_string: input string to be parsed
:param parse_t... | parse_time_variables | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def _get_tron_k8s_cluster_override(cluster: str) -> Optional[str]:
"""
Return the name of a compute cluster if there's a different compute cluster that should be used to run a Tronjob.
Will return None if no override mapping is present
We have certain Tron masters that are named differently from the co... |
Return the name of a compute cluster if there's a different compute cluster that should be used to run a Tronjob.
Will return None if no override mapping is present
We have certain Tron masters that are named differently from the compute cluster that should actually be used (
e.g., we might have tron-... | _get_tron_k8s_cluster_override | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def get_secret_volumes(self) -> List[TronSecretVolume]: # type: ignore
"""Adds the secret_volume_name to the object so tron/task_processing can load it downstream without replicating code."""
secret_volumes = super().get_secret_volumes()
tron_secret_volumes = []
for secret_volume in sec... | Adds the secret_volume_name to the object so tron/task_processing can load it downstream without replicating code. | get_secret_volumes | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def get_node_affinities(self) -> Optional[List[Dict[str, Union[str, List[str]]]]]:
"""Converts deploy_whitelist and deploy_blacklist in node affinities.
NOTE: At the time of writing, `kubectl describe` does not show affinities,
only selectors. To see affinities, use `kubectl get pod -o json` in... | Converts deploy_whitelist and deploy_blacklist in node affinities.
NOTE: At the time of writing, `kubectl describe` does not show affinities,
only selectors. To see affinities, use `kubectl get pod -o json` instead.
WARNING: At the time of writing, we only used requiredDuringSchedulingIgnoredD... | get_node_affinities | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def get_pool(self) -> str:
"""
Returns the default pool override if pool is not defined in the action configuration.
This is useful for environments like spam to allow us to default the pool to spam but allow users to
override this value. To control this, we have an optional config item... |
Returns the default pool override if pool is not defined in the action configuration.
This is useful for environments like spam to allow us to default the pool to spam but allow users to
override this value. To control this, we have an optional config item that we'll puppet onto Tron masters
... | get_pool | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def format_tron_job_dict(job_config: TronJobConfig, k8s_enabled: bool = False):
"""Generate a dict of tronfig for a job, from the TronJobConfig.
:param job_config: TronJobConfig
"""
action_dict = {
action_config.get_action_name(): format_tron_action_dict(
action_config=action_config... | Generate a dict of tronfig for a job, from the TronJobConfig.
:param job_config: TronJobConfig
| format_tron_job_dict | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def load_tron_service_config_no_cache(
service,
cluster,
load_deployments=True,
soa_dir=DEFAULT_SOA_DIR,
for_validation=False,
):
"""Load all configured jobs for a service, and any additional config values."""
config = read_extra_service_information(
service_name=service, extra_info=... | Load all configured jobs for a service, and any additional config values. | load_tron_service_config_no_cache | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def create_complete_config(
service: str,
cluster: str,
soa_dir: str = DEFAULT_SOA_DIR,
k8s_enabled: bool = False,
dry_run: bool = False,
):
"""Generate a namespace configuration file for Tron, for a service."""
job_configs = load_tron_service_config(
service=service,
cluster... | Generate a namespace configuration file for Tron, for a service. | create_complete_config | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def list_tron_clusters(service: str, soa_dir: str = DEFAULT_SOA_DIR) -> List[str]:
"""Returns the Tron clusters a service is configured to deploy to."""
search_re = r"/tron-([0-9a-z-_]*)\.yaml$"
service_dir = os.path.join(soa_dir, service)
clusters = []
for filename in glob.glob(f"{service_dir}/*.ya... | Returns the Tron clusters a service is configured to deploy to. | list_tron_clusters | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def parse_service_instance_from_executor_id(task_id: str) -> Tuple[str, str]:
"""Parses tron mesos task ids, like schematizer.traffic_generator.28414.turnstyle.46da87d7-6092-4ed4-b926-ffa7b21c7785"""
try:
service, job, job_run, action, uuid = task_id.split(".")
except Exception as e:
log.war... | Parses tron mesos task ids, like schematizer.traffic_generator.28414.turnstyle.46da87d7-6092-4ed4-b926-ffa7b21c7785 | parse_service_instance_from_executor_id | python | Yelp/paasta | paasta_tools/tron_tools.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/tron_tools.py | Apache-2.0 |
def get_namespace(self) -> str:
"""Get namespace from config, default to the value from INSTANCE_TYPE_TO_K8S_NAMESPACE for this instance type, 'paasta' if that isn't defined."""
return self.config_dict.get(
"namespace",
INSTANCE_TYPE_TO_K8S_NAMESPACE.get(self.get_instance_type(),... | Get namespace from config, default to the value from INSTANCE_TYPE_TO_K8S_NAMESPACE for this instance type, 'paasta' if that isn't defined. | get_namespace | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_cpu_quota(self) -> float:
"""Gets the --cpu-quota option to be passed to docker
Calculation: (cpus + cpus_burst_add) * cfs_period_us
:returns: The number to be passed to the --cpu-quota docker flag"""
cpu_burst_add = self.get_cpu_burst_add()
return (self.get_cpus() + cp... | Gets the --cpu-quota option to be passed to docker
Calculation: (cpus + cpus_burst_add) * cfs_period_us
:returns: The number to be passed to the --cpu-quota docker flag | get_cpu_quota | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_cap_add(self) -> Iterable[DockerParameter]:
"""Get the --cap-add options to be passed to docker
Generated from the cap_add configuration option, which is a list of
capabilities.
Example configuration: {'cap_add': ['IPC_LOCK', 'SYS_PTRACE']}
:returns: A generator of cap_... | Get the --cap-add options to be passed to docker
Generated from the cap_add configuration option, which is a list of
capabilities.
Example configuration: {'cap_add': ['IPC_LOCK', 'SYS_PTRACE']}
:returns: A generator of cap_add options to be passed as --cap-add flags | get_cap_add | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_cap_drop(self) -> Iterable[DockerParameter]:
"""Generates --cap-drop options to be passed to docker by default, which
makes them not able to perform special privilege escalation stuff
https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
"""
... | Generates --cap-drop options to be passed to docker by default, which
makes them not able to perform special privilege escalation stuff
https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
| get_cap_drop | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_cap_args(self) -> Iterable[DockerParameter]:
"""Generate all --cap-add/--cap-drop parameters, ensuring not to have overlapping settings"""
cap_adds = list(self.get_cap_add())
if cap_adds and is_using_unprivileged_containers():
log.warning(
"Unprivileged contai... | Generate all --cap-add/--cap-drop parameters, ensuring not to have overlapping settings | get_cap_args | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def format_docker_parameters(
self,
with_labels: bool = True,
system_paasta_config: Optional["SystemPaastaConfig"] = None,
) -> List[DockerParameter]:
"""Formats extra flags for running docker. Will be added in the format
`["--%s=%s" % (e['key'], e['value']) for e in list]` ... | Formats extra flags for running docker. Will be added in the format
`["--%s=%s" % (e['key'], e['value']) for e in list]` to the `docker run` command
Note: values must be strings
:param with_labels: Whether to build docker parameters with or without labels
:returns: A list of parameters... | format_docker_parameters | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.