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 paasta_validate_soa_configs( service: str, service_path: str, verbose: bool = False ) -> bool: """Analyze the service in service_path to determine if the conf files are valid :param service_path: Path to directory containing soa conf yaml files for service """ if not check_service_path(service_...
Analyze the service in service_path to determine if the conf files are valid :param service_path: Path to directory containing soa conf yaml files for service
paasta_validate_soa_configs
python
Yelp/paasta
paasta_tools/cli/cmds/validate.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/validate.py
Apache-2.0
def paasta_validate(args): """Generate a service_path from the provided args and call paasta_validate_soa_configs :param args: argparse.Namespace obj created from sys.args by cli """ service_path = get_service_path(args.service, args.yelpsoa_config_root) service = args.service or guess_service_name...
Generate a service_path from the provided args and call paasta_validate_soa_configs :param args: argparse.Namespace obj created from sys.args by cli
paasta_validate
python
Yelp/paasta
paasta_tools/cli/cmds/validate.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/validate.py
Apache-2.0
def get_latest_marked_version( git_url: str, deploy_group: str ) -> Optional[DeploymentVersion]: """Return the latest marked for deployment version or None""" # TODO: correct this function for new tag format refs = list_remote_refs(git_url) _, sha, image_version = get_latest_deployment_tag(refs, dep...
Return the latest marked for deployment version or None
get_latest_marked_version
python
Yelp/paasta
paasta_tools/cli/cmds/wait_for_deployment.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/wait_for_deployment.py
Apache-2.0
def validate_version_is_latest( version: DeploymentVersion, git_url: str, deploy_group: str, service: str ): """Verify if the requested version is the latest marked for deployment. Raise exception when the provided version is not the latest marked for deployment in 'deploy_group' for 'service'. ""...
Verify if the requested version is the latest marked for deployment. Raise exception when the provided version is not the latest marked for deployment in 'deploy_group' for 'service'.
validate_version_is_latest
python
Yelp/paasta
paasta_tools/cli/cmds/wait_for_deployment.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/wait_for_deployment.py
Apache-2.0
def validate_deploy_group(deploy_group: str, service: str, soa_dir: str): """Validate deploy_group. Raise exception if the specified deploy group is not used anywhere. """ in_use_deploy_groups = list_deploy_groups(service=service, soa_dir=soa_dir) _, invalid_deploy_groups = validate_given_deploy_gr...
Validate deploy_group. Raise exception if the specified deploy group is not used anywhere.
validate_deploy_group
python
Yelp/paasta
paasta_tools/cli/cmds/wait_for_deployment.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/wait_for_deployment.py
Apache-2.0
def _get_smartstack_proxy_ports_from_file(root, file): """Given a root and file (as from os.walk), attempt to return the highest smartstack proxy port number (int) from that file. Returns 0 if there is no smartstack proxy_port. """ ports = set() with open(os.path.join(root, file)) as f: ...
Given a root and file (as from os.walk), attempt to return the highest smartstack proxy port number (int) from that file. Returns 0 if there is no smartstack proxy_port.
_get_smartstack_proxy_ports_from_file
python
Yelp/paasta
paasta_tools/cli/fsm/autosuggest.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/fsm/autosuggest.py
Apache-2.0
def suggest_smartstack_proxy_port( yelpsoa_config_root, range_min=19000, range_max=21000 ): """Pick a random available port in the 19000-21000 block""" available_proxy_ports = set(range(range_min, range_max + 1)) for root, dirs, files in os.walk(yelpsoa_config_root): for f in files: ...
Pick a random available port in the 19000-21000 block
suggest_smartstack_proxy_port
python
Yelp/paasta
paasta_tools/cli/fsm/autosuggest.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/fsm/autosuggest.py
Apache-2.0
def get_deploy_durations_from_file(filename): """ filename: path to a file to be parsed for datetime data The expected input is a paasta service log for the deploy events The way I've been fetching them is by running 'internal logreader command' | grep deploy | grep event > filename """ file_obj...
filename: path to a file to be parsed for datetime data The expected input is a paasta service log for the deploy events The way I've been fetching them is by running 'internal logreader command' | grep deploy | grep event > filename
get_deploy_durations_from_file
python
Yelp/paasta
paasta_tools/contrib/bounce_log_latency_parser.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/contrib/bounce_log_latency_parser.py
Apache-2.0
def host_to_ip(host: str, fallback: str) -> str: """Try to resolve a host to an IP with a fallback. Because DNS resolution is relatively slow and can't be easily performed using asyncio, we cheat a little and use a regex for well-formed hostnames to try to guess the IP without doing real resolution. ...
Try to resolve a host to an IP with a fallback. Because DNS resolution is relatively slow and can't be easily performed using asyncio, we cheat a little and use a regex for well-formed hostnames to try to guess the IP without doing real resolution. A fallback is needed because in some cases the nerve ...
host_to_ip
python
Yelp/paasta
paasta_tools/contrib/check_orphans.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/contrib/check_orphans.py
Apache-2.0
def get_container_type(container_name: str, instance_name: str) -> str: """ To differentiate between main service containers and sidecars """ if instance_name and container_name == kubernetes_tools.sanitise_kubernetes_name( instance_name ): return MAIN_CONTAINER_TYPE else: ...
To differentiate between main service containers and sidecars
get_container_type
python
Yelp/paasta
paasta_tools/contrib/get_running_task_allocation.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/contrib/get_running_task_allocation.py
Apache-2.0
def get_report_from_splunk(creds, app, filename, criteria_filter): """Expect a table containing at least the following fields: criteria (<service> kubernetes-<cluster_name> <instance>) service_owner (Optional) project (Required to create tickets) estimated_monthly_savings (Optional) search_time ...
Expect a table containing at least the following fields: criteria (<service> kubernetes-<cluster_name> <instance>) service_owner (Optional) project (Required to create tickets) estimated_monthly_savings (Optional) search_time (Unix time) one of the following pairs: - current_cpus and suggest...
get_report_from_splunk
python
Yelp/paasta
paasta_tools/contrib/paasta_update_soa_memcpu.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/contrib/paasta_update_soa_memcpu.py
Apache-2.0
def get_reviewers_in_group(group_name): """Using rbt's target-groups argument overrides our configured default review groups. So we'll expand the group into usernames and pass those users in the group individually. """ rightsizer_reviewers = json.loads( subprocess.check_output( ( ...
Using rbt's target-groups argument overrides our configured default review groups. So we'll expand the group into usernames and pass those users in the group individually.
get_reviewers_in_group
python
Yelp/paasta
paasta_tools/contrib/paasta_update_soa_memcpu.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/contrib/paasta_update_soa_memcpu.py
Apache-2.0
def nested_inc(op, _, attr_val, attr_name, state, step=1): """Increments relevant counter by step from args array""" oph = state.setdefault(op, {}) nameh = oph.setdefault(attr_name, {}) nameh.setdefault(attr_val, 0) nameh[attr_val] += step return state
Increments relevant counter by step from args array
nested_inc
python
Yelp/paasta
paasta_tools/frameworks/constraints.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/constraints.py
Apache-2.0
def check_offer_constraints(offer, constraints, state): """Returns True if all constraints are satisfied by offer's attributes, returns False otherwise. Prints a error message and re-raises if an error was thrown.""" for (attr, op, val) in constraints: try: offer_attr = next((x for x...
Returns True if all constraints are satisfied by offer's attributes, returns False otherwise. Prints a error message and re-raises if an error was thrown.
check_offer_constraints
python
Yelp/paasta
paasta_tools/frameworks/constraints.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/constraints.py
Apache-2.0
def update_constraint_state(offer, constraints, state, step=1): """Mutates state for each offer attribute found in constraints by calling relevant UPDATE_OP lambda""" for (attr, op, val) in constraints: for oa in offer.attributes: if attr == oa.name: UPDATE_OPS[op](val, o...
Mutates state for each offer attribute found in constraints by calling relevant UPDATE_OP lambda
update_constraint_state
python
Yelp/paasta
paasta_tools/frameworks/constraints.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/constraints.py
Apache-2.0
def launch_tasks_for_offers( self, driver: MesosSchedulerDriver, offers ) -> List[TaskInfo]: """For each offer tries to launch all tasks that can fit in there. Declines offer if no fitting tasks found.""" launched_tasks: List[TaskInfo] = [] for offer in offers: w...
For each offer tries to launch all tasks that can fit in there. Declines offer if no fitting tasks found.
launch_tasks_for_offers
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def task_fits(self, offer): """Checks whether the offer is big enough to fit the tasks""" needed_resources = { "cpus": self.service_config.get_cpus(), "mem": self.service_config.get_mem(), "disk": self.service_config.get_disk(), } for resource in offer...
Checks whether the offer is big enough to fit the tasks
task_fits
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def need_more_tasks(self, name, existingTasks, scheduledTasks): """Returns whether we need to start more tasks.""" num_have = 0 for task, parameters in existingTasks.items(): if self.is_task_new(name, task) and ( parameters.mesos_task_state in LIVE_TASK_STATES ...
Returns whether we need to start more tasks.
need_more_tasks
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def tasks_and_state_for_offer( self, driver: MesosSchedulerDriver, offer, state: ConstraintState ) -> Tuple[List[TaskInfo], ConstraintState]: """Returns collection of tasks that can fit inside an offer.""" tasks: List[TaskInfo] = [] offerCpus = 0.0 offerMem = 0.0 offe...
Returns collection of tasks that can fit inside an offer.
tasks_and_state_for_offer
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def healthiness_score(task_id): """Return a tuple that can be used as a key for sorting, that expresses our desire to keep this task around. Higher values (things that sort later) are more desirable.""" params = all_tasks_with_params[task_id] state_score = { ...
Return a tuple that can be used as a key for sorting, that expresses our desire to keep this task around. Higher values (things that sort later) are more desirable.
healthiness_score
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def get_happy_tasks(self, tasks_with_params: Dict[str, MesosTaskParameters]): """Filter a dictionary of tasks->params to those that are running and not draining.""" happy_tasks = {} for tid, params in tasks_with_params.items(): if params.mesos_task_state == TASK_RUNNING and not param...
Filter a dictionary of tasks->params to those that are running and not draining.
get_happy_tasks
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def make_drain_task(self, task_id: str): """Return a DrainTask object, which is suitable for passing to drain methods.""" ports = [] params = self.task_store.get_task(task_id) for resource in params.resources: if resource["name"] == "ports": for rg in resour...
Return a DrainTask object, which is suitable for passing to drain methods.
make_drain_task
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def recreate_drain_method(self) -> None: """Re-instantiate self.drain_method. Should be called after self.service_config changes.""" self.drain_method = drain_lib.get_drain_method( name=self.service_config.get_drain_method( self.service_config.service_namespace_config ...
Re-instantiate self.drain_method. Should be called after self.service_config changes.
recreate_drain_method
python
Yelp/paasta
paasta_tools/frameworks/native_scheduler.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_scheduler.py
Apache-2.0
def base_task( self, system_paasta_config: SystemPaastaConfig, portMappings=True ) -> TaskInfo: """Return a TaskInfo Dict with all the fields corresponding to the configuration filled in. Does not include task.agent_id or a task.id; those need to be computed separately. ...
Return a TaskInfo Dict with all the fields corresponding to the configuration filled in. Does not include task.agent_id or a task.id; those need to be computed separately.
base_task
python
Yelp/paasta
paasta_tools/frameworks/native_service_config.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/native_service_config.py
Apache-2.0
def merge(self: _SelfT, **kwargs) -> "MesosTaskParameters": """Return a merged MesosTaskParameters object, where attributes in other take precedence over self.""" new_dict = copy.deepcopy(self.__dict__) new_dict.update(kwargs) return MesosTaskParameters(**new_dict)
Return a merged MesosTaskParameters object, where attributes in other take precedence over self.
merge
python
Yelp/paasta
paasta_tools/frameworks/task_store.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/task_store.py
Apache-2.0
def add_task_if_doesnt_exist(self, task_id: str, **kwargs) -> None: """Add a task if it does not already exist. If it already exists, do nothing.""" if self.get_task(task_id) is not None: return else: self.overwrite_task(task_id, MesosTaskParameters(**kwargs))
Add a task if it does not already exist. If it already exists, do nothing.
add_task_if_doesnt_exist
python
Yelp/paasta
paasta_tools/frameworks/task_store.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/task_store.py
Apache-2.0
def _get_task(self, task_id: str) -> Tuple[MesosTaskParameters, ZnodeStat]: """Like get_task, but also returns the ZnodeStat that self.zk_client.get() returns""" try: data, stat = self.zk_client.get("/%s" % task_id) return MesosTaskParameters.deserialize(data), stat excep...
Like get_task, but also returns the ZnodeStat that self.zk_client.get() returns
_get_task
python
Yelp/paasta
paasta_tools/frameworks/task_store.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/frameworks/task_store.py
Apache-2.0
def _format_remote_run_job_name( job: V1Job, user: str, ) -> str: """Format name for remote run job :param V1Job job: job definition :param str user: the user requesting the remote-run :return: job name """ return limit_size_with_hash(f"remote-run-{user}-{job.metadata.name}")
Format name for remote run job :param V1Job job: job definition :param str user: the user requesting the remote-run :return: job name
_format_remote_run_job_name
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def remote_run_start( service: str, instance: str, cluster: str, user: str, interactive: bool, recreate: bool, max_duration: int, is_toolbox: bool, ) -> RemoteRunOutcome: """Trigger remote-run job :param str service: service name :param str instance: service instance :pa...
Trigger remote-run job :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :param str user: the user requesting the remote-run sandbox :param bool interactive: whether it is expected to access the remote-run job interactively :param bool rec...
remote_run_start
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def remote_run_ready( service: str, instance: str, cluster: str, job_name: str, user: str, is_toolbox: bool, ) -> RemoteRunOutcome: """Check if remote-run pod is ready :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :...
Check if remote-run pod is ready :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :param str job_name: name of the remote-run job to check :param bool is_toolbox: requested job is for a toolbox container :return: job status, with pod info...
remote_run_ready
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def remote_run_stop( service: str, instance: str, cluster: str, user: str, is_toolbox: bool, ) -> RemoteRunOutcome: """Stop remote-run job :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :param str user: the user requesti...
Stop remote-run job :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :param str user: the user requesting the remote-run sandbox :param bool is_toolbox: requested job is for a toolbox container :return: outcome of the operation
remote_run_stop
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def remote_run_token( service: str, instance: str, cluster: str, user: str, ) -> str: """Creates a short lived token for execing into a pod :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :param str user: the user requesting ...
Creates a short lived token for execing into a pod :param str service: service name :param str instance: service instance :param str cluster: paasta cluster :param str user: the user requesting the remote-run sandbox
remote_run_token
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def generate_toolbox_deployment( service: str, cluster: str, user: str ) -> EksDeploymentConfig: """Creates virtual EKS deployment for toolbox containers starting from adhoc configuration :param str service: toolbox name :param str cluster: target deployment cluster :param str user: user requesting...
Creates virtual EKS deployment for toolbox containers starting from adhoc configuration :param str service: toolbox name :param str cluster: target deployment cluster :param str user: user requesting the toolbox :return: deployment configuration
generate_toolbox_deployment
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def find_job_pod( kube_client: KubeClient, namespace: str, job_name: str, job_label: str = REMOTE_RUN_JOB_LABEL, retries: int = 3, ) -> Optional[V1Pod]: """Locate pod for remote-run job :param KubeClient kube_client: Kubernetes client :param str namespace: the pod namespace :param s...
Locate pod for remote-run job :param KubeClient kube_client: Kubernetes client :param str namespace: the pod namespace :param str job_name: remote-run job name :param int retries: maximum number of attemps :return: pod object if found
find_job_pod
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def create_temp_exec_token( kube_client: KubeClient, namespace: str, service_account: str, ) -> str: """Create a short lived token for service account :param KubeClient kube_client: Kubernetes client :param str namespace: service account namespace :param str service_account: service account...
Create a short lived token for service account :param KubeClient kube_client: Kubernetes client :param str namespace: service account namespace :param str service_account: service account name :return: token value
create_temp_exec_token
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def get_remote_run_service_accounts( kube_client: KubeClient, namespace: str, user: str = "" ) -> Sequence[V1ServiceAccount]: """List all temporary service account related to remote-run :param KubeClient kube_client: Kubernetes client :param str namespace: pod namespace :param str user: optionally ...
List all temporary service account related to remote-run :param KubeClient kube_client: Kubernetes client :param str namespace: pod namespace :param str user: optionally filter by owning user :return: list of service accounts
get_remote_run_service_accounts
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def create_remote_run_service_account( kube_client: KubeClient, namespace: str, pod_name: str, user: str, ) -> str: """Create service account to exec into remote-run pod :param KubeClient kube_client: Kubernetes client :param str namespace: pod namespace :param str pod_name: pod name ...
Create service account to exec into remote-run pod :param KubeClient kube_client: Kubernetes client :param str namespace: pod namespace :param str pod_name: pod name :param str user: user requiring credentials
create_remote_run_service_account
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def create_pod_scoped_role( kube_client: KubeClient, namespace: str, pod_name: str, user: str, ) -> str: """Create role with execution access to specific pod :param KubeClient kube_client: Kubernetes client :param str namespace: pod namespace :param str pod_name: pod name :param str...
Create role with execution access to specific pod :param KubeClient kube_client: Kubernetes client :param str namespace: pod namespace :param str pod_name: pod name :param str user: user requiring the role :return: name of the role
create_pod_scoped_role
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def bind_role_to_service_account( kube_client: KubeClient, namespace: str, service_account: str, role: str, user: str, ) -> None: """Bind service account to role :param KubeClient kube_client: Kubernetes client :param str namespace: service account namespace :param str service_accou...
Bind service account to role :param KubeClient kube_client: Kubernetes client :param str namespace: service account namespace :param str service_account: service account name :param str role: role name :param str user: user requiring the role
bind_role_to_service_account
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def get_remote_run_roles(kube_client: KubeClient, namespace: str) -> List[V1Role]: """List all temporary roles related to remote-run :param KubeClient kube_client: Kubernetes client :param str namespace: role namespace :return: list of roles """ return kube_client.rbac.list_namespaced_role( ...
List all temporary roles related to remote-run :param KubeClient kube_client: Kubernetes client :param str namespace: role namespace :return: list of roles
get_remote_run_roles
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def get_remote_run_role_bindings( kube_client: KubeClient, namespace: str ) -> List[V1RoleBinding]: """List all temporary role bindings related to remote-run :param KubeClient kube_client: Kubernetes client :param str namespace: role namespace :return: list of roles """ return kube_client.r...
List all temporary role bindings related to remote-run :param KubeClient kube_client: Kubernetes client :param str namespace: role namespace :return: list of roles
get_remote_run_role_bindings
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def get_remote_run_jobs(kube_client: KubeClient, namespace: str) -> List[V1Job]: """List all remote-run jobs :param KubeClient kube_client: Kubernetes client :param str namespace: job namespace """ return kube_client.batches.list_namespaced_job( namespace, label_selector=f"{paasta_p...
List all remote-run jobs :param KubeClient kube_client: Kubernetes client :param str namespace: job namespace
get_remote_run_jobs
python
Yelp/paasta
paasta_tools/kubernetes/remote_run.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/remote_run.py
Apache-2.0
def __init__( self, item: Union[V1Deployment, V1StatefulSet], logging=logging.getLogger(__name__), ) -> None: """ This Application wrapper is an interface for creating/deleting k8s deployments and statefulsets soa_config is KubernetesDeploymentConfig. It is not loaded...
This Application wrapper is an interface for creating/deleting k8s deployments and statefulsets soa_config is KubernetesDeploymentConfig. It is not loaded in init because it is not always required. :param item: Kubernetes Object(V1Deployment/V1StatefulSet) that has already been filled up. ...
__init__
python
Yelp/paasta
paasta_tools/kubernetes/application/controller_wrappers.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/application/controller_wrappers.py
Apache-2.0
def ensure_service_account(self, kube_client: KubeClient) -> None: """ Ensure that the service account for this application exists :param kube_client: """ if self.soa_config.get_iam_role(): ensure_service_account( iam_role=self.soa_config.get_iam_role(...
Ensure that the service account for this application exists :param kube_client:
ensure_service_account
python
Yelp/paasta
paasta_tools/kubernetes/application/controller_wrappers.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/application/controller_wrappers.py
Apache-2.0
def deep_delete( self, kube_client: KubeClient, propagation_policy="Foreground" ) -> None: """ Remove all controllers, pods, and pod disruption budgets related to this application :param kube_client: """ delete_options = V1DeleteOptions(propagation_policy=propagation_...
Remove all controllers, pods, and pod disruption budgets related to this application :param kube_client:
deep_delete
python
Yelp/paasta
paasta_tools/kubernetes/application/controller_wrappers.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/application/controller_wrappers.py
Apache-2.0
def sync_horizontal_pod_autoscaler(self, kube_client: KubeClient) -> None: """ In order for autoscaling to work, there needs to be at least two configurations min_instnace, max_instance, and there cannot be instance. """ desired_hpa_spec = self.soa_config.get_autoscaling_metric_s...
In order for autoscaling to work, there needs to be at least two configurations min_instnace, max_instance, and there cannot be instance.
sync_horizontal_pod_autoscaler
python
Yelp/paasta
paasta_tools/kubernetes/application/controller_wrappers.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/application/controller_wrappers.py
Apache-2.0
def deep_delete(self, kube_client: KubeClient) -> None: """Remove resources related to the job""" delete_options = V1DeleteOptions(propagation_policy="Foreground") try: kube_client.batches.delete_namespaced_job( self.item.metadata.name, self.item.metad...
Remove resources related to the job
deep_delete
python
Yelp/paasta
paasta_tools/kubernetes/application/controller_wrappers.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/application/controller_wrappers.py
Apache-2.0
def list_all_applications( kube_client: KubeClient, application_types: Sequence[Any] ) -> Dict[Tuple[str, str], List[Application]]: """ List all applications in the cluster of the types from application_types. Only applications with complete set of labels are included (See is_valid_application()). :...
List all applications in the cluster of the types from application_types. Only applications with complete set of labels are included (See is_valid_application()). :param kube_client: :param application_types: types of applications :return: A mapping from (service, instance) to application
list_all_applications
python
Yelp/paasta
paasta_tools/kubernetes/application/tools.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/application/tools.py
Apache-2.0
def set_temporary_environment_variables( environ: Mapping[str, str] ) -> Generator[None, None, None]: """ *Note the return value means "yields None, takes None, and when finished, returns None"* Modifies the os.environ variable then yields this temporary state. Resets it when finished. :param envi...
*Note the return value means "yields None, takes None, and when finished, returns None"* Modifies the os.environ variable then yields this temporary state. Resets it when finished. :param environ: Environment variables to set
set_temporary_environment_variables
python
Yelp/paasta
paasta_tools/kubernetes/bin/paasta_secrets_sync.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/bin/paasta_secrets_sync.py
Apache-2.0
def get_services_to_k8s_namespaces_to_allowlist( service_list: List[str], cluster: str, soa_dir: str, kube_client: KubeClient ) -> Dict[ str, # service Dict[ str, # namespace Optional[Set[str]], # allowlist of secret names, None means allow all. ], ]: """ Generate a mapping of...
Generate a mapping of service -> namespace -> allowlist of secrets, e.g. { "yelp-main": { "paasta": {"secret1", "secret2"}, "paastasvc-yelp-main": {"secret1", "secret3"}, "paasta-flinks": None, }, "_shared": { "paasta": {"sharedsecret1"},...
get_services_to_k8s_namespaces_to_allowlist
python
Yelp/paasta
paasta_tools/kubernetes/bin/paasta_secrets_sync.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/bin/paasta_secrets_sync.py
Apache-2.0
def sync_datastore_credentials( kube_client: KubeClient, cluster: str, service: str, secret_provider_name: str, vault_cluster_config: Dict[str, str], soa_dir: str, vault_token_file: str, overwrite_namespace: Optional[str] = None, ) -> bool: """ Map all the passwords requested for...
Map all the passwords requested for this service-instance to a single Kubernetes Secret store. Volume mounts will then map the associated secrets to their associated mount paths.
sync_datastore_credentials
python
Yelp/paasta
paasta_tools/kubernetes/bin/paasta_secrets_sync.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/bin/paasta_secrets_sync.py
Apache-2.0
def sync_crypto_secrets( kube_client: KubeClient, cluster: str, service: str, secret_provider_name: str, vault_cluster_config: Dict[str, str], soa_dir: str, vault_token_file: str, ) -> bool: """ For each key-name in `crypto_key`, 1. Fetch all versions of the key-name from Vault s...
For each key-name in `crypto_key`, 1. Fetch all versions of the key-name from Vault superregion mapped from cluster, e.g. `kubestage` maps to `devc` Vault server. 2. Create K8s secret from JSON blob containing all key versions. 3. Create signatures as K8s configmap based on JSON blob hash. So each...
sync_crypto_secrets
python
Yelp/paasta
paasta_tools/kubernetes/bin/paasta_secrets_sync.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/bin/paasta_secrets_sync.py
Apache-2.0
def create_or_update_k8s_secret( service: str, secret_name: str, signature_name: str, get_secret_data: Callable[[], Dict[str, str]], secret_signature: str, kube_client: KubeClient, namespace: str, ) -> None: """ :param get_secret_data: is a function to postpone fetching data in order...
:param get_secret_data: is a function to postpone fetching data in order to reduce service load, e.g. Vault API
create_or_update_k8s_secret
python
Yelp/paasta
paasta_tools/kubernetes/bin/paasta_secrets_sync.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/kubernetes/bin/paasta_secrets_sync.py
Apache-2.0
def resolve(self, cfg): """Resolve the URL to the mesos master. The value of cfg should be one of: - host:port - zk://host1:port1,host2:port2/path - zk://username:password@host1:port1/path - file:///path/to/file (where file contains one of the above) ...
Resolve the URL to the mesos master. The value of cfg should be one of: - host:port - zk://host1:port1,host2:port2/path - zk://username:password@host1:port1/path - file:///path/to/file (where file contains one of the above)
resolve
python
Yelp/paasta
paasta_tools/mesos/master.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos/master.py
Apache-2.0
def stream(fn, elements, workers): """Yield the results of fn as jobs complete.""" jobs = [] with execute(workers) as executor: for elem in elements: jobs.append(executor.submit(fn, elem)) for job in concurrent.futures.as_completed(jobs): try: yield ...
Yield the results of fn as jobs complete.
stream
python
Yelp/paasta
paasta_tools/mesos/parallel.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/mesos/parallel.py
Apache-2.0
def get_num_masters() -> int: """Gets the number of masters from mesos state""" zookeeper_host_path = get_zookeeper_host_path() return get_number_of_mesos_masters( zookeeper_host_path.host, zookeeper_host_path.path )
Gets the number of masters from mesos state
get_num_masters
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_mesos_cpu_status( metrics: MesosMetrics, mesos_state: MesosState ) -> Tuple[int, int, int]: """Takes in the mesos metrics and analyzes them, returning the status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and availa...
Takes in the mesos metrics and analyzes them, returning the status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and available CPUs.
get_mesos_cpu_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_kube_cpu_status( nodes: Sequence[V1Node], ) -> Tuple[float, float, float]: """Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available CPUs. """ total = 0.0 available = 0.0 ...
Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available CPUs.
get_kube_cpu_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_mesos_memory_status( metrics: MesosMetrics, mesos_state: MesosState ) -> Tuple[int, int, int]: """Takes in the mesos metrics and analyzes them, returning the status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and ava...
Takes in the mesos metrics and analyzes them, returning the status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and available memory in Mi.
get_mesos_memory_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_kube_memory_status( nodes: Sequence[V1Node], ) -> Tuple[float, float, float]: """Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available memory in Mi. """ total = 0.0 availab...
Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available memory in Mi.
get_kube_memory_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_mesos_disk_status( metrics: MesosMetrics, mesos_state: MesosState ) -> Tuple[int, int, int]: """Takes in the mesos metrics and analyzes them, returning the status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and avail...
Takes in the mesos metrics and analyzes them, returning the status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and available disk space in Mi.
get_mesos_disk_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_kube_disk_status( nodes: Sequence[V1Node], ) -> Tuple[float, float, float]: """Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available disk space in Mi. """ total = 0.0 avai...
Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available disk space in Mi.
get_kube_disk_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_mesos_gpu_status( metrics: MesosMetrics, mesos_state: MesosState ) -> Tuple[int, int, int]: """Takes in the mesos metrics and analyzes them, returning gpus status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and avail...
Takes in the mesos metrics and analyzes them, returning gpus status. :param metrics: mesos metrics dictionary. :param mesos_state: mesos state dictionary. :returns: Tuple of total, used, and available GPUs.
get_mesos_gpu_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_kube_gpu_status( nodes: Sequence[V1Node], ) -> Tuple[float, float, float]: """Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available GPUs. """ total = 0.0 available = 0.0 ...
Takes in the list of Kubernetes nodes and analyzes them, returning the status. :param nodes: list of Kubernetes nodes. :returns: Tuple of total, used, and available GPUs.
get_kube_gpu_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def healthcheck_result_for_resource_utilization( resource_utilization: ResourceUtilization, threshold: int ) -> HealthCheckResult: """Given a resource data dict, assert that cpu data is ok. :param resource_utilization: the resource_utilization tuple to check :returns: a HealthCheckResult """ ...
Given a resource data dict, assert that cpu data is ok. :param resource_utilization: the resource_utilization tuple to check :returns: a HealthCheckResult
healthcheck_result_for_resource_utilization
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def key_func_for_attribute( attribute: str, ) -> Callable[[_SlaveT], str]: """Return a closure that given a slave, will return the value of a specific attribute. :param attribute: the attribute to inspect in the slave :returns: a closure, which takes a slave and returns the value of an attribute ...
Return a closure that given a slave, will return the value of a specific attribute. :param attribute: the attribute to inspect in the slave :returns: a closure, which takes a slave and returns the value of an attribute
key_func_for_attribute
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def key_func_for_attribute_multi( attributes: Sequence[str], ) -> _GenericNodeGroupingFunctionT: """Return a closure that given a slave, will return the value of a list of attributes, compiled into a hashable tuple :param attributes: the attributes to inspect in the slave :returns: a closure, which...
Return a closure that given a slave, will return the value of a list of attributes, compiled into a hashable tuple :param attributes: the attributes to inspect in the slave :returns: a closure, which takes a slave and returns the value of those attributes
key_func_for_attribute_multi
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def key_func_for_attribute_multi_kube( attributes: Sequence[str], ) -> Callable[[V1Node], _KeyFuncRetT]: """Return a closure that given a node, will return the value of a list of attributes, compiled into a hashable tuple :param attributes: the attributes to inspect in the slave :returns: a closure...
Return a closure that given a node, will return the value of a list of attributes, compiled into a hashable tuple :param attributes: the attributes to inspect in the slave :returns: a closure, which takes a node and returns the value of those attributes
key_func_for_attribute_multi_kube
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def group_slaves_by_key_func( key_func: _GenericNodeGroupingFunctionT, slaves: Sequence[_GenericNodeT], sort_func: _GenericNodeSortFunctionT = None, ) -> Mapping[_KeyFuncRetT, Sequence[_GenericNodeT]]: """Given a function for grouping slaves, return a dict where keys are the unique values returned b...
Given a function for grouping slaves, return a dict where keys are the unique values returned by the key_func and the values are all those slaves which have that specific value. :param key_func: a function which consumes a slave and returns a value :param slaves: a list of slaves :returns: a di...
group_slaves_by_key_func
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def calculate_resource_utilization_for_slaves( slaves: Sequence[_SlaveT], tasks: Sequence[MesosTask] ) -> ResourceUtilizationDict: """Given a list of slaves and a list of tasks, calculate the total available resource available in that list of slaves, and the resources consumed by tasks running on those ...
Given a list of slaves and a list of tasks, calculate the total available resource available in that list of slaves, and the resources consumed by tasks running on those slaves. :param slaves: a list of slaves to calculate resource usage for :param tasks: the list of tasks running in the mesos cluster ...
calculate_resource_utilization_for_slaves
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def calculate_resource_utilization_for_kube_nodes( nodes: Sequence[V1Node], pods_by_node: Mapping[str, Sequence[V1Pod]], ) -> ResourceUtilizationDict: """Given a list of Kubernetes nodes, calculate the total available resource available and the resources consumed in that list of nodes. :param nodes...
Given a list of Kubernetes nodes, calculate the total available resource available and the resources consumed in that list of nodes. :param nodes: a list of Kubernetes nodes to calculate resource usage for :returns: a dict, containing keys for "free" and "total" resources. Each of these keys is a Resou...
calculate_resource_utilization_for_kube_nodes
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def filter_tasks_for_slaves( slaves: Sequence[_SlaveT], tasks: Sequence[MesosTask] ) -> Sequence[MesosTask]: """Given a list of slaves and a list of tasks, return a filtered list of tasks, where those returned belong to slaves in the list of slaves :param slaves: the list of slaves which the tasks ...
Given a list of slaves and a list of tasks, return a filtered list of tasks, where those returned belong to slaves in the list of slaves :param slaves: the list of slaves which the tasks provided should be running on. :param tasks: the tasks to filter :returns: a list of tasks, identical to tha...
filter_tasks_for_slaves
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def filter_slaves( slaves: Sequence[_GenericNodeT], filters: Sequence[_GenericNodeFilterFunctionT] ) -> Sequence[_GenericNodeT]: """Filter slaves by attributes :param slaves: list of slaves to filter :param filters: list of functions that take a slave and return whether the slave should be included...
Filter slaves by attributes :param slaves: list of slaves to filter :param filters: list of functions that take a slave and return whether the slave should be included :returns: list of slaves that return true for all the filters
filter_slaves
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_resource_utilization_by_grouping( grouping_func: _GenericNodeGroupingFunctionT, mesos_state: MesosState, filters: Sequence[_GenericNodeFilterFunctionT] = [], sort_func: _GenericNodeSortFunctionT = None, ) -> Mapping[_KeyFuncRetT, ResourceUtilizationDict]: """Given a function used to group sl...
Given a function used to group slaves and mesos state, calculate resource utilization for each value of a given attribute. :grouping_func: a function that given a slave, will return the value of an attribute to group by. :param mesos_state: the mesos state :param filters: filters to apply to the sl...
get_resource_utilization_by_grouping
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_resource_utilization_by_grouping_kube( grouping_func: _GenericNodeGroupingFunctionT, kube_client: KubeClient, *, namespace: str, filters: Sequence[_GenericNodeFilterFunctionT] = [], sort_func: _GenericNodeSortFunctionT = None, ) -> Mapping[_KeyFuncRetT, ResourceUtilizationDict]: """G...
Given a function used to group nodes, calculate resource utilization for each value of a given attribute. :grouping_func: a function that given a node, will return the value of an attribute to group by. :param kube_client: the Kubernetes client :param filters: filters to apply to the nodes in the c...
get_resource_utilization_by_grouping_kube
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def resource_utillizations_from_resource_info( total: ResourceInfo, free: ResourceInfo ) -> Sequence[ResourceUtilization]: """ Given two ResourceInfo tuples, one for total and one for free, create a ResourceUtilization tuple for each metric in the ResourceInfo. :param total: :param free: :re...
Given two ResourceInfo tuples, one for total and one for free, create a ResourceUtilization tuple for each metric in the ResourceInfo. :param total: :param free: :returns: ResourceInfo for a metric
resource_utillizations_from_resource_info
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def has_registered_slaves( mesos_state: MesosState, ) -> bool: """Return a boolean indicating if there are any slaves registered to the master according to the mesos state. :param mesos_state: the mesos state from the master :returns: a boolean, indicating if there are > 0 slaves """ return ...
Return a boolean indicating if there are any slaves registered to the master according to the mesos state. :param mesos_state: the mesos state from the master :returns: a boolean, indicating if there are > 0 slaves
has_registered_slaves
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_kube_resource_utilization_health( kube_client: KubeClient, ) -> Sequence[HealthCheckResult]: """Perform healthchecks against Kubernetes. :param kube_client: the KUbernetes client :returns: a list of HealthCheckResult tuples """ nodes = get_all_nodes_cached(kube_client) return [ ...
Perform healthchecks against Kubernetes. :param kube_client: the KUbernetes client :returns: a list of HealthCheckResult tuples
get_kube_resource_utilization_health
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_kube_status( kube_client: KubeClient, namespace: str ) -> Sequence[HealthCheckResult]: """Gather information about Kubernetes. :param kube_client: the KUbernetes client :return: string containing the status """ return run_healthchecks_with_param( [kube_client, namespace], [assert...
Gather information about Kubernetes. :param kube_client: the KUbernetes client :return: string containing the status
get_kube_status
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def critical_events_in_outputs(healthcheck_outputs): """Given a list of HealthCheckResults return those which are unhealthy.""" return [ healthcheck for healthcheck in healthcheck_outputs if healthcheck.healthy is False ]
Given a list of HealthCheckResults return those which are unhealthy.
critical_events_in_outputs
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def generate_summary_for_check(name, ok): """Given a check name and a boolean indicating if the service is OK, return a formatted message. """ status = PaastaColors.green("OK") if ok is True else PaastaColors.red("CRITICAL") summary = f"{name} Status: {status}" return summary
Given a check name and a boolean indicating if the service is OK, return a formatted message.
generate_summary_for_check
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def healthcheck_result_resource_utilization_pair_for_resource_utilization( utilization, threshold ): """Given a ResourceUtilization, produce a tuple of (HealthCheckResult, ResourceUtilization), where that HealthCheckResult describes the 'health' of a given utilization. :param utilization: a ResourceUtil...
Given a ResourceUtilization, produce a tuple of (HealthCheckResult, ResourceUtilization), where that HealthCheckResult describes the 'health' of a given utilization. :param utilization: a ResourceUtilization tuple :param threshold: a threshold which decides the health of the given ResourceUtilization :r...
healthcheck_result_resource_utilization_pair_for_resource_utilization
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def format_table_column_for_healthcheck_resource_utilization_pair( healthcheck_utilization_pair, ): """Given a tuple of (HealthCheckResult, ResourceUtilization), return a string representation of the ResourceUtilization such that it is formatted according to the value of HealthCheckResult.healthy. ...
Given a tuple of (HealthCheckResult, ResourceUtilization), return a string representation of the ResourceUtilization such that it is formatted according to the value of HealthCheckResult.healthy. :param healthcheck_utilization_pair: a tuple of (HealthCheckResult, ResourceUtilization) :returns: a string...
format_table_column_for_healthcheck_resource_utilization_pair
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def format_row_for_resource_utilization_healthchecks(healthcheck_utilization_pairs): """Given a list of (HealthCheckResult, ResourceUtilization) tuples, return a list with each of those tuples represented by a formatted string. :param healthcheck_utilization_pairs: a list of (HealthCheckResult, ResourceUti...
Given a list of (HealthCheckResult, ResourceUtilization) tuples, return a list with each of those tuples represented by a formatted string. :param healthcheck_utilization_pairs: a list of (HealthCheckResult, ResourceUtilization) tuples. :returns: a list containing a string representation of each (HealthChe...
format_row_for_resource_utilization_healthchecks
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def get_table_rows_for_resource_info_dict( attribute_values, healthcheck_utilization_pairs ): """A wrapper method to join together :param attribute: The attribute value and formatted columns to be shown in a single row. :param attribute_value: The value of the attribute associated with the row. Th...
A wrapper method to join together :param attribute: The attribute value and formatted columns to be shown in a single row. :param attribute_value: The value of the attribute associated with the row. This becomes index 0 in the array returned. :param healthcheck_utilization_pairs: a list of 2-tuples, w...
get_table_rows_for_resource_info_dict
python
Yelp/paasta
paasta_tools/metrics/metastatus_lib.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/metrics/metastatus_lib.py
Apache-2.0
def pool(self): """Create thread pool on first request avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: atexit.register(self.close) self._pool = ThreadPool(self.pool_threads) return self._pool
Create thread pool on first request avoids instantiating unused threadpool for blocking clients.
pool
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def sanitize_for_serialization(cls, obj): """Builds a JSON POST object. If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. If obj is list, sanitize each e...
Builds a JSON POST object. If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date convert to string in iso8601 format. If obj is list, sanitize each element in the list. If obj is dict, return th...
sanitize_for_serialization
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def deserialize(self, response, response_type, _check_type): """Deserializes response into an object. :param response: RESTResponse object to be deserialized. :param response_type: For the response, a tuple containing: valid classes a list containing valid classes (for l...
Deserializes response into an object. :param response: RESTResponse object to be deserialized. :param response_type: For the response, a tuple containing: valid classes a list containing valid classes (for list schemas) a dict containing a tuple of valid classes as t...
deserialize
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def call_api( self, resource_path: str, method: str, path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, ...
Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. :param resource_path: Path to method endpoint. :param method: Method to call. :param path_params: Path parameters in the url. :param query_params: Quer...
call_api
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None): """Makes the HTTP request using RESTClient.""" if method == "GET": return self.rest_client.GET(url, ...
Makes the HTTP request using RESTClient.
request
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def parameters_to_tuples(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. :param params: Parameters as dict or list of two-tuples :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collection...
Get parameters as list of tuples, formatting collections. :param params: Parameters as dict or list of two-tuples :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted
parameters_to_tuples
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): """Builds form parameters. :param files: None or a dict with key=param_name and value is a list of open file objects :return: List of tuples of form parameters with file data ...
Builds form parameters. :param files: None or a dict with key=param_name and value is a list of open file objects :return: List of tuples of form parameters with file data
files_parameters
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def select_header_accept(self, accepts): """Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. :return: Accept (e.g. application/json). """ if not accepts: return accepts = [x.lower() for x in accepts] if 'appli...
Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. :return: Accept (e.g. application/json).
select_header_accept
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def select_header_content_type(self, content_types): """Returns `Content-Type` based on an array of content_types provided. :param content_types: List of content-types. :return: Content-Type (e.g. application/json). """ if not content_types: return 'application/json'...
Returns `Content-Type` based on an array of content_types provided. :param content_types: List of content-types. :return: Content-Type (e.g. application/json).
select_header_content_type
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def update_params_for_auth(self, headers, querys, auth_settings, resource_path, method, body): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to b...
Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. :param resource_path: A string representation o...
update_params_for_auth
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def __init__(self, settings=None, params_map=None, root_map=None, headers_map=None, api_client=None, callable=None): """Creates an endpoint Args: settings (dict): see below key value pairs 'response_type' (tuple/None): response type 'auth' (l...
Creates an endpoint Args: settings (dict): see below key value pairs 'response_type' (tuple/None): response type 'auth' (list): a list of auth type keys 'endpoint_path' (str): the endpoint path 'operation_id' (str): endpoint string ide...
__init__
python
Yelp/paasta
paasta_tools/paastaapi/api_client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api_client.py
Apache-2.0
def get_default_copy(cls): """Return new instance of configuration. This method returns newly created, based on default constructor, object of Configuration class or returns a copy of default configuration passed by the set_default method. :return: The configuration object. ...
Return new instance of configuration. This method returns newly created, based on default constructor, object of Configuration class or returns a copy of default configuration passed by the set_default method. :return: The configuration object.
get_default_copy
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def logger_file(self, value): """The logger file. If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler. :param value: The logger_file path. :type: str """ self.__logger_file = value ...
The logger file. If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler. :param value: The logger_file path. :type: str
logger_file
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def debug(self, value): """Debug status :param value: The debug status, True or False. :type: bool """ self.__debug = value if self.__debug: # if debug status is True, turn on debug logging for _, logger in self.logger.items(): log...
Debug status :param value: The debug status, True or False. :type: bool
debug
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def logger_format(self, value): """The logger format. The logger_formatter will be updated when sets logger_format. :param value: The format string. :type: str """ self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format)
The logger format. The logger_formatter will be updated when sets logger_format. :param value: The format string. :type: str
logger_format
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0