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 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 |
def get_container_type(self) -> Optional[str]:
"""Get Mesos containerizer type.
Default to DOCKER if gpus are not used.
:returns: Mesos containerizer type, DOCKER or MESOS"""
if self.get_gpus() is not None:
container_type = "MESOS"
else:
container_type =... | Get Mesos containerizer type.
Default to DOCKER if gpus are not used.
:returns: Mesos containerizer type, DOCKER or MESOS | get_container_type | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_env_dictionary(
self, system_paasta_config: Optional["SystemPaastaConfig"] = None
) -> Dict[str, str]:
"""A dictionary of key/value pairs that represent environment variables
to be injected to the container environment"""
env = {
"PAASTA_SERVICE": self.service,
... | A dictionary of key/value pairs that represent environment variables
to be injected to the container environment | get_env_dictionary | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_env(
self, system_paasta_config: Optional["SystemPaastaConfig"] = None
) -> Dict[str, str]:
"""Basic get_env that simply returns the basic env, other classes
might need to override this getter for more implementation-specific
env getting"""
return self.get_env_diction... | Basic get_env that simply returns the basic env, other classes
might need to override this getter for more implementation-specific
env getting | get_env | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_args(self) -> Optional[List[str]]:
"""Get the docker args specified in the service's configuration.
If not specified in the config and if cmd is not specified, defaults to an empty array.
If not specified in the config but cmd is specified, defaults to null.
If specified in the ... | Get the docker args specified in the service's configuration.
If not specified in the config and if cmd is not specified, defaults to an empty array.
If not specified in the config but cmd is specified, defaults to null.
If specified in the config and if cmd is also specified, throws an excepti... | get_args | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_deploy_constraints(
self,
blacklist: DeployBlacklist,
whitelist: DeployWhitelist,
system_deploy_blacklist: DeployBlacklist,
system_deploy_whitelist: DeployWhitelist,
) -> List[Constraint]:
"""Return the combination of deploy_blacklist and deploy_whitelist
... | Return the combination of deploy_blacklist and deploy_whitelist
as a list of constraints.
| get_deploy_constraints | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_docker_image(self) -> str:
"""Get the docker image name (with tag) for a given service branch from
a generated deployments.json file."""
if self.branch_dict is not None:
return self.branch_dict["docker_image"]
else:
return "" | Get the docker image name (with tag) for a given service branch from
a generated deployments.json file. | get_docker_image | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_image_version(self) -> Optional[str]:
"""Get additional information identifying the Docker image from a
generated deployments.json file."""
if self.branch_dict is not None and "image_version" in self.branch_dict:
return self.branch_dict["image_version"]
else:
... | Get additional information identifying the Docker image from a
generated deployments.json file. | get_image_version | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_desired_state(self) -> str:
"""Get the desired state (either 'start' or 'stop') for a given service
branch from a generated deployments.json file."""
if self.branch_dict is not None:
return self.branch_dict["desired_state"]
else:
return "start" | Get the desired state (either 'start' or 'stop') for a given service
branch from a generated deployments.json file. | get_desired_state | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_force_bounce(self) -> Optional[str]:
"""Get the force_bounce token for a given service branch from a generated
deployments.json file. This is a token that, when changed, indicates that
the instance should be recreated and bounced, even if no other
parameters have changed. This ma... | Get the force_bounce token for a given service branch from a generated
deployments.json file. This is a token that, when changed, indicates that
the instance should be recreated and bounced, even if no other
parameters have changed. This may be None or a string, generally a
timestamp.
... | get_force_bounce | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_dependencies(self) -> Optional[Dict]:
"""Get the contents of the dependencies_dict pointed to by the dependency_reference or
'main' if no dependency_reference exists
Defaults to None if not specified in the config.
:returns: A list of dictionaries specified in the dependencies_... | Get the contents of the dependencies_dict pointed to by the dependency_reference or
'main' if no dependency_reference exists
Defaults to None if not specified in the config.
:returns: A list of dictionaries specified in the dependencies_dict, None if not specified
| get_dependencies | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_outbound_firewall(self) -> Optional[str]:
"""Return 'block', 'monitor', or None as configured in security->outbound_firewall
Defaults to None if not specified in the config
:returns: A string specified in the config, None if not specified"""
security = self.config_dict.get("sec... | Return 'block', 'monitor', or None as configured in security->outbound_firewall
Defaults to None if not specified in the config
:returns: A string specified in the config, None if not specified | get_outbound_firewall | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def color_text(color: str, text: str) -> str:
"""Return text that can be printed color.
:param color: ANSI color code
:param text: a string
:return: a string with ANSI color encoding"""
if os.getenv("NO_COLOR", "0") == "1":
return text
# any time text retur... | Return text that can be printed color.
:param color: ANSI color code
:param text: a string
:return: a string with ANSI color encoding | color_text | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_git_url(service: str, soa_dir: str = DEFAULT_SOA_DIR) -> str:
"""Get the git url for a service. Assumes that the service's
repo matches its name, and that it lives in services- i.e.
if this is called with the string 'test', the returned
url will be git@github.yelpcorp.com:services/test.
:pa... | Get the git url for a service. Assumes that the service's
repo matches its name, and that it lives in services- i.e.
if this is called with the string 'test', the returned
url will be git@github.yelpcorp.com:services/test.
:param service: The service name to get a URL for
:returns: A git url to the... | get_git_url | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def register_log_writer(name: str) -> Callable[[_LogWriterTypeT], _LogWriterTypeT]:
"""Returns a decorator that registers that log writer class at a given name
so get_log_writer_class can find it."""
def outer(log_writer_class: _LogWriterTypeT) -> _LogWriterTypeT:
_log_writer_classes[name] = log_wr... | Returns a decorator that registers that log writer class at a given name
so get_log_writer_class can find it. | register_log_writer | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def configure_log() -> None:
"""We will log to the yocalhost binded scribe."""
log_writer_config = load_system_paasta_config().get_log_writer()
global _log_writer
LogWriterClass = get_log_writer_class(log_writer_config["driver"])
_log_writer = LogWriterClass(**log_writer_config.get("options", {})) | We will log to the yocalhost binded scribe. | configure_log | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def format_log_line(
level: str,
cluster: str,
service: str,
instance: str,
component: str,
line: str,
timestamp: str = None,
) -> str:
"""Accepts a string 'line'.
Returns an appropriately-formatted dictionary which can be serialized to
JSON for logging and which contains 'line'... | Accepts a string 'line'.
Returns an appropriately-formatted dictionary which can be serialized to
JSON for logging and which contains 'line'.
| format_log_line | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def format_audit_log_line(
cluster: str,
instance: str,
user: str,
host: str,
action: str,
action_details: dict = None,
service: str = None,
timestamp: str = None,
) -> str:
"""Accepts:
* a string 'user' describing the user that initiated the action
* a string 'host'... | Accepts:
* a string 'user' describing the user that initiated the action
* a string 'host' describing the server where the user initiated the action
* a string 'action' describing an action performed by paasta_tools
* a dict 'action_details' optional information about the action
Re... | format_audit_log_line | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def log(
self,
service: str,
line: str,
component: str,
level: str = DEFAULT_LOGLEVEL,
cluster: str = ANY_CLUSTER,
instance: str = ANY_INSTANCE,
) -> None:
"""This expects someone (currently the paasta cli main()) to... | This expects someone (currently the paasta cli main()) to have already
configured the log object. We'll just write things to it.
| log | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def timed_flock(fd: _AnyIO, seconds: int = 1) -> Iterator[None]:
"""Attempt to grab an exclusive flock with a timeout. Uses Timeout, so will
raise a TimeoutError if `seconds` elapses before the flock can be obtained
"""
# We don't want to wrap the user code in the timeout, just the flock grab
flock_... | Attempt to grab an exclusive flock with a timeout. Uses Timeout, so will
raise a TimeoutError if `seconds` elapses before the flock can be obtained
| timed_flock | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def _timeout(process: Popen) -> None:
"""Helper function for _run. It terminates the process.
Doesn't raise OSError, if we try to terminate a non-existing
process as there can be a very small window between poll() and kill()
"""
if process.poll() is None:
try:
# sending SIGKILL t... | Helper function for _run. It terminates the process.
Doesn't raise OSError, if we try to terminate a non-existing
process as there can be a very small window between poll() and kill()
| _timeout | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_readable_files_in_glob(glob: str, path: str) -> List[str]:
"""
Returns a sorted list of files that are readable in an input glob by recursively searching a path
"""
globbed_files = []
for root, dirs, files in os.walk(path):
for f in files:
fn = os.path.join(root, f)
... |
Returns a sorted list of files that are readable in an input glob by recursively searching a path
| get_readable_files_in_glob | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def load_system_paasta_config(
path: str = PATH_TO_SYSTEM_PAASTA_CONFIG_DIR,
) -> "SystemPaastaConfig":
"""
Reads Paasta configs in specified directory in lexicographical order and deep merges
the dictionaries (last file wins).
"""
if not os.path.isdir(path):
raise PaastaNotConfiguredErr... |
Reads Paasta configs in specified directory in lexicographical order and deep merges
the dictionaries (last file wins).
| load_system_paasta_config | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def optionally_load_system_paasta_config(
path: str = PATH_TO_SYSTEM_PAASTA_CONFIG_DIR,
) -> "SystemPaastaConfig":
"""
Tries to load the system paasta config, but will return an empty configuration if not available,
without raising.
"""
try:
return load_system_paasta_config(path=path)
... |
Tries to load the system paasta config, but will return an empty configuration if not available,
without raising.
| optionally_load_system_paasta_config | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def parse_system_paasta_config(
file_stats: FrozenSet[Tuple[str, os.stat_result]], path: str
) -> "SystemPaastaConfig":
"""Pass in a dictionary of filename -> os.stat_result, and this returns the merged parsed configs"""
config: SystemPaastaConfigDict = {}
for filename, _ in file_stats:
with ope... | Pass in a dictionary of filename -> os.stat_result, and this returns the merged parsed configs | parse_system_paasta_config | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_default_spark_driver_pool_override(self) -> str:
"""
If defined, fetches the override for what pool to run a Spark driver in.
Otherwise, returns the default Spark driver pool.
:returns: The default_spark_driver_pool_override specified in the paasta configuration
"""
... |
If defined, fetches the override for what pool to run a Spark driver in.
Otherwise, returns the default Spark driver pool.
:returns: The default_spark_driver_pool_override specified in the paasta configuration
| get_default_spark_driver_pool_override | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_zk_hosts(self) -> str:
"""Get the zk_hosts defined in this hosts's cluster config file.
Strips off the zk:// prefix, if it exists, for use with Kazoo.
:returns: The zk_hosts specified in the paasta configuration
"""
try:
hosts = self.config_dict["zookeeper"]
... | Get the zk_hosts defined in this hosts's cluster config file.
Strips off the zk:// prefix, if it exists, for use with Kazoo.
:returns: The zk_hosts specified in the paasta configuration
| get_zk_hosts | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_system_docker_registry(self) -> str:
"""Get the docker_registry defined in this host's cluster config file.
:returns: The docker_registry specified in the paasta configuration
"""
try:
return self.config_dict["docker_registry"]
except KeyError:
ra... | Get the docker_registry defined in this host's cluster config file.
:returns: The docker_registry specified in the paasta configuration
| get_system_docker_registry | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_hacheck_sidecar_volumes(self) -> List[DockerVolume]:
"""Get the hacheck sidecar volumes defined in this host's hacheck_sidecar_volumes config file.
:returns: The list of volumes specified in the paasta configuration
"""
try:
volumes = self.config_dict["hacheck_sideca... | Get the hacheck sidecar volumes defined in this host's hacheck_sidecar_volumes config file.
:returns: The list of volumes specified in the paasta configuration
| get_hacheck_sidecar_volumes | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_volumes(self) -> Sequence[DockerVolume]:
"""Get the volumes defined in this host's volumes config file.
:returns: The list of volumes specified in the paasta configuration
"""
try:
return self.config_dict["volumes"]
except KeyError:
raise PaastaNo... | Get the volumes defined in this host's volumes config file.
:returns: The list of volumes specified in the paasta configuration
| get_volumes | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_cluster(self) -> str:
"""Get the cluster defined in this host's cluster config file.
:returns: The name of the cluster defined in the paasta configuration
"""
try:
return self.config_dict["cluster"]
except KeyError:
raise PaastaNotConfiguredError(... | Get the cluster defined in this host's cluster config file.
:returns: The name of the cluster defined in the paasta configuration
| get_cluster | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_log_writer(self) -> LogWriterConfig:
"""Get the log_writer configuration out of global paasta config
:returns: The log_writer dictionary.
"""
try:
return self.config_dict["log_writer"]
except KeyError:
raise PaastaNotConfiguredError(
... | Get the log_writer configuration out of global paasta config
:returns: The log_writer dictionary.
| get_log_writer | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_log_reader(self) -> LogReaderConfig:
"""Get the log_reader configuration out of global paasta config
:returns: the log_reader dictionary.
"""
try:
return self.config_dict["log_reader"]
except KeyError:
raise PaastaNotConfiguredError(
... | Get the log_reader configuration out of global paasta config
:returns: the log_reader dictionary.
| get_log_reader | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_log_readers(self) -> List[LogReaderConfig]:
"""Get the log_readers configuration out of global paasta config
:returns: the log_readers list of dicts.
"""
try:
return self.config_dict["log_readers"]
except KeyError:
raise PaastaNotConfiguredError(
... | Get the log_readers configuration out of global paasta config
:returns: the log_readers list of dicts.
| get_log_readers | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_metrics_provider(self) -> Optional[str]:
"""Get the metrics_provider configuration out of global paasta config
:returns: A string identifying the metrics_provider
"""
deployd_metrics_provider = self.config_dict.get("deployd_metrics_provider")
if deployd_metrics_provider ... | Get the metrics_provider configuration out of global paasta config
:returns: A string identifying the metrics_provider
| get_metrics_provider | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_synapse_haproxy_url_format(self) -> str:
"""Get a format string for the URL to query for haproxy-synapse state. This format string gets two keyword
arguments, host and port. Defaults to "http://{host:s}:{port:d}/;csv;norefresh".
:returns: A format string for constructing the URL of hapr... | Get a format string for the URL to query for haproxy-synapse state. This format string gets two keyword
arguments, host and port. Defaults to "http://{host:s}:{port:d}/;csv;norefresh".
:returns: A format string for constructing the URL of haproxy-synapse's status page.
| get_synapse_haproxy_url_format | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_envoy_admin_endpoint_format(self) -> str:
"""Get the format string for Envoy's admin interface."""
return self.config_dict.get(
"envoy_admin_endpoint_format", "http://{host:s}:{port:d}/{endpoint:s}"
) | Get the format string for Envoy's admin interface. | get_envoy_admin_endpoint_format | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_envoy_admin_port(self) -> int:
"""Get the port that Envoy's admin interface is listening on
from /etc/services."""
return socket.getservbyname(
self.config_dict.get("envoy_admin_domain_name", "envoy-admin")
) | Get the port that Envoy's admin interface is listening on
from /etc/services. | get_envoy_admin_port | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_git_config(self) -> Dict:
"""Gets git configuration. Includes repo names and their git servers.
:returns: the git config dict
"""
return self.config_dict.get(
"git_config",
{
"git_user": "git",
"repos": {
... | Gets git configuration. Includes repo names and their git servers.
:returns: the git config dict
| get_git_config | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_gunicorn_exporter_sidecar_image_url(self) -> str:
"""Get the docker image URL for the gunicorn_exporter sidecar container"""
return self.config_dict.get(
"gunicorn_exporter_sidecar_image_url",
"docker-paasta.yelpcorp.com:443/gunicorn_exporter-k8s-sidecar:v0.24.0-yelp0",
... | Get the docker image URL for the gunicorn_exporter sidecar container | get_gunicorn_exporter_sidecar_image_url | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_readiness_check_prefix_template(self) -> List[str]:
"""A prefix that will be added to the beginning of the readiness check command. Meant for e.g. `flock` and
`timeout`."""
# We use flock+timeout here to work around issues discovered in PAASTA-17673:
# In k8s 1.18, probe timeout ... | A prefix that will be added to the beginning of the readiness check command. Meant for e.g. `flock` and
`timeout`. | get_readiness_check_prefix_template | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def _run(
command: Union[str, List[str]],
env: Mapping[str, str] = os.environ,
timeout: float = None,
log: bool = False,
stream: bool = False,
stdin: Any = None,
stdin_interrupt: bool = False,
popen_kwargs: Dict = {},
**kwargs: Any,
) -> Tuple[int, str]:
"""Given a command, run i... | Given a command, run it. Return a tuple of the return code and any
output.
:param timeout: If specified, the command will be terminated after timeout
seconds.
:param log: If True, the _log will be handled by _run. If set, it is mandatory
to pass at least a :service: and a :component: parame... | _run | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_umask() -> int:
"""Get the current umask for this process. NOT THREAD SAFE."""
old_umask = os.umask(0o0022)
os.umask(old_umask)
return old_umask | Get the current umask for this process. NOT THREAD SAFE. | get_umask | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def compose_job_id(
name: str,
instance: str,
git_hash: Optional[str] = None,
config_hash: Optional[str] = None,
spacer: str = SPACER,
) -> str:
"""Compose a job/app id by concatenating its name, instance, git hash, and config hash.
:param name: The name of the service
:param instance: ... | Compose a job/app id by concatenating its name, instance, git hash, and config hash.
:param name: The name of the service
:param instance: The instance of the service
:param git_hash: The git_hash portion of the job_id. If git_hash is set,
config_hash must also be set.
:param confi... | compose_job_id | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def decompose_job_id(job_id: str, spacer: str = SPACER) -> Tuple[str, str, str, str]:
"""Break a composed job id into its constituent (service name, instance,
git hash, config hash) by splitting with ``spacer``.
:param job_id: The composed id of the job/app
:returns: A tuple (service name, instance, gi... | Break a composed job id into its constituent (service name, instance,
git hash, config hash) by splitting with ``spacer``.
:param job_id: The composed id of the job/app
:returns: A tuple (service name, instance, git hash, config hash) that
comprise the job_id
| decompose_job_id | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def build_docker_image_name(service: str) -> str:
"""docker-paasta.yelpcorp.com:443 is the URL for the Registry where PaaSTA
will look for your images.
:returns: a sanitized-for-Jenkins (s,/,-,g) version of the
service's path in git. E.g. For github.yelpcorp.com:services/foo the
docker image name i... | docker-paasta.yelpcorp.com:443 is the URL for the Registry where PaaSTA
will look for your images.
:returns: a sanitized-for-Jenkins (s,/,-,g) version of the
service's path in git. E.g. For github.yelpcorp.com:services/foo the
docker image name is docker_registry/services-foo.
| build_docker_image_name | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def check_docker_image(
service: str,
commit: str,
image_version: Optional[str] = None,
) -> bool:
"""Checks whether the given image for :service: with :tag: exists.
:raises: ValueError if more than one docker image with :tag: found.
:returns: True if there is exactly one matching image found.
... | Checks whether the given image for :service: with :tag: exists.
:raises: ValueError if more than one docker image with :tag: found.
:returns: True if there is exactly one matching image found.
| check_docker_image | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_files_of_type_in_dir(
file_type: str,
service: str = None,
soa_dir: str = DEFAULT_SOA_DIR,
) -> List[str]:
"""Recursively search path if type of file exists.
:param file_type: a string of a type of a file (kubernetes, slo, etc.)
:param service: a string of a service
:param soa_dir: ... | Recursively search path if type of file exists.
:param file_type: a string of a type of a file (kubernetes, slo, etc.)
:param service: a string of a service
:param soa_dir: a string of a path to a soa_configs directory
:return: a list
| get_files_of_type_in_dir | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def list_clusters(
service: str = None, soa_dir: str = DEFAULT_SOA_DIR, instance_type: str = None
) -> List[str]:
"""Returns a sorted list of clusters a service is configured to deploy to,
or all clusters if ``service`` is not specified.
Includes every cluster that has a ``kubernetes-*.yaml`` or ``tron... | Returns a sorted list of clusters a service is configured to deploy to,
or all clusters if ``service`` is not specified.
Includes every cluster that has a ``kubernetes-*.yaml`` or ``tron-*.yaml`` file associated with it.
:param service: The service name. If unspecified, clusters running any service will b... | list_clusters | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_service_instance_list_no_cache(
service: str,
cluster: Optional[str] = None,
instance_type: str = None,
soa_dir: str = DEFAULT_SOA_DIR,
) -> List[Tuple[str, str]]:
"""Enumerate the instances defined for a service as a list of tuples.
:param service: The service name
:param cluster: ... | Enumerate the instances defined for a service as a list of tuples.
:param service: The service name
:param cluster: The cluster to read the configuration for
:param instance_type: The type of instances to examine: 'kubernetes', 'tron', or None (default) for both
:param soa_dir: The SOA config directory... | get_service_instance_list_no_cache | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_services_for_cluster(
cluster: str = None, instance_type: str = None, soa_dir: str = DEFAULT_SOA_DIR
) -> List[Tuple[str, str]]:
"""Retrieve all services and instances defined to run in a cluster.
:param cluster: The cluster to read the configuration for
:param instance_type: The type of instan... | Retrieve all services and instances defined to run in a cluster.
:param cluster: The cluster to read the configuration for
:param instance_type: The type of instances to examine: 'kubernetes', 'tron', or None (default) for both
:param soa_dir: The SOA config directory to read from
:returns: A list of t... | get_services_for_cluster | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_latest_deployment_tag(
refs: Dict[str, str], deploy_group: str
) -> Tuple[str, str, Optional[str]]:
"""Gets the latest deployment tag and sha for the specified deploy_group
:param refs: A dictionary mapping git refs to shas
:param deploy_group: The deployment group to return a deploy tag for
... | Gets the latest deployment tag and sha for the specified deploy_group
:param refs: A dictionary mapping git refs to shas
:param deploy_group: The deployment group to return a deploy tag for
:returns: A tuple of the form (ref, sha, image_version) where ref is the
actual deployment tag (with t... | get_latest_deployment_tag | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_config_hash(config: Any, force_bounce: str = None) -> str:
"""Create an MD5 hash of the configuration dictionary to be sent to
Kubernetes. Or anything really, so long as str(config) works. Returns
the first 8 characters so things are not really long.
:param config: The configuration to hash
... | Create an MD5 hash of the configuration dictionary to be sent to
Kubernetes. Or anything really, so long as str(config) works. Returns
the first 8 characters so things are not really long.
:param config: The configuration to hash
:param force_bounce: a timestamp (in the form of a string) that is append... | get_config_hash | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_git_sha_from_dockerurl(docker_url: str, long: bool = False) -> str:
"""We encode the sha of the code that built a docker image *in* the docker
url. This function takes that url as input and outputs the sha.
"""
if ":paasta-" in docker_url:
deployment_version = get_deployment_version_from... | We encode the sha of the code that built a docker image *in* the docker
url. This function takes that url as input and outputs the sha.
| get_git_sha_from_dockerurl | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_image_version_from_dockerurl(docker_url: str) -> Optional[str]:
"""We can optionally encode additional metadata about the docker image *in*
the docker url. This function takes that url as input and outputs the sha.
"""
deployment_version = get_deployment_version_from_dockerurl(docker_url)
re... | We can optionally encode additional metadata about the docker image *in*
the docker url. This function takes that url as input and outputs the sha.
| get_image_version_from_dockerurl | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def is_under_replicated(
num_available: int, expected_count: int, crit_threshold: int
) -> Tuple[bool, float]:
"""Calculates if something is under replicated
:param num_available: How many things are up
:param expected_count: How many things you think should be up
:param crit_threshold: Int from 0-... | Calculates if something is under replicated
:param num_available: How many things are up
:param expected_count: How many things you think should be up
:param crit_threshold: Int from 0-100
:returns: Tuple of (bool, ratio)
| is_under_replicated | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def deploy_blacklist_to_constraints(
deploy_blacklist: DeployBlacklist,
) -> List[Constraint]:
"""Converts a blacklist of locations into tron appropriate constraints.
:param blacklist: List of lists of locations to blacklist
:returns: List of lists of constraints
"""
constraints: List[Constrain... | Converts a blacklist of locations into tron appropriate constraints.
:param blacklist: List of lists of locations to blacklist
:returns: List of lists of constraints
| deploy_blacklist_to_constraints | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def deploy_whitelist_to_constraints(
deploy_whitelist: DeployWhitelist,
) -> List[Constraint]:
"""Converts a whitelist of locations into tron appropriate constraints
:param deploy_whitelist: List of lists of locations to whitelist
:returns: List of lists of constraints
"""
if deploy_whitelist i... | Converts a whitelist of locations into tron appropriate constraints
:param deploy_whitelist: List of lists of locations to whitelist
:returns: List of lists of constraints
| deploy_whitelist_to_constraints | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def format_table(
rows: Iterable[Union[str, Sequence[str]]], min_spacing: int = 2
) -> List[str]:
"""Formats a table for use on the command line.
:param rows: List of rows, each of which can either be a tuple of strings containing the row's values, or a string
to be inserted verbatim. Each... | Formats a table for use on the command line.
:param rows: List of rows, each of which can either be a tuple of strings containing the row's values, or a string
to be inserted verbatim. Each row (except literal strings) should be the same number of elements as
all the others.
:... | format_table | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def is_deploy_step(step: str) -> bool:
"""
Returns true if the given step deploys to an instancename
Returns false if the step is a predefined step-type, e.g. itest or command-*
"""
return not (
(step in DEPLOY_PIPELINE_NON_DEPLOY_STEPS) or (step.startswith("command-"))
) |
Returns true if the given step deploys to an instancename
Returns false if the step is a predefined step-type, e.g. itest or command-*
| is_deploy_step | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def ldap_user_search(
cn: str,
search_base: str,
search_ou: str,
ldap_host: str,
username: str,
password: str,
) -> Set[str]:
"""Connects to LDAP and raises a subclass of LDAPOperationResult when it fails"""
tls_config = ldap3.Tls(
validate=ssl.CERT_REQUIRED, ca_certs_file="/etc/... | Connects to LDAP and raises a subclass of LDAPOperationResult when it fails | ldap_user_search | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def get_k8s_url_for_cluster(cluster: str) -> Optional[str]:
"""
Annoyingly, there's two layers of aliases: one to figure out what
k8s server url to use (this one) and another to figure out what
soaconfigs filename to use ;_;
This exists so that we can map something like `--cluster pnw-devc`
int... |
Annoyingly, there's two layers of aliases: one to figure out what
k8s server url to use (this one) and another to figure out what
soaconfigs filename to use ;_;
This exists so that we can map something like `--cluster pnw-devc`
into spark-pnw-devc's k8s apiserver url without needing to update
... | get_k8s_url_for_cluster | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def maybe_load_previous_config(
filename: str, config_loader: Callable[[TextIO], dict]
) -> Optional[dict]:
"""Try to load configuration file
:param str filename: path to load from
:param Callable[[TextIO], dict] config_loader: parser for the configuration
:return: configuration data, None if loadi... | Try to load configuration file
:param str filename: path to load from
:param Callable[[TextIO], dict] config_loader: parser for the configuration
:return: configuration data, None if loading fails
| maybe_load_previous_config | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def write_json_configuration_file(filename: str, configuration: dict) -> None:
"""Atomically write configuration to JSON file
:param str filename: path to write to
:param dict configuration: configuration data
"""
with atomic_file_write(filename) as fp:
json.dump(
obj=configurat... | Atomically write configuration to JSON file
:param str filename: path to write to
:param dict configuration: configuration data
| write_json_configuration_file | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def write_yaml_configuration_file(
filename: str, configuration: dict, check_existing: bool = True
) -> None:
"""Atomically write configuration to YAML file
:param str filename: path to write to
:param dict configuration: configuration data
:param bool check_existing: if existing file already match... | Atomically write configuration to YAML file
:param str filename: path to write to
:param dict configuration: configuration data
:param bool check_existing: if existing file already matches config, do not overwrite
| write_yaml_configuration_file | python | Yelp/paasta | paasta_tools/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/utils.py | Apache-2.0 |
def __call__(self, request: Request) -> Response:
"""
Extracts relevant metadata from request, and checks if it is authorized
"""
token = request.headers.get("Authorization", "").strip()
token = token.split()[-1] if token else "" # removes "Bearer" prefix
auth_outcome = ... |
Extracts relevant metadata from request, and checks if it is authorized
| __call__ | python | Yelp/paasta | paasta_tools/api/tweens/auth.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/api/tweens/auth.py | Apache-2.0 |
def is_request_authorized(
self,
path: str,
token: str,
method: str,
service: Optional[str],
) -> AuthorizationOutcome:
"""Check if API request is authorized
:param str path: API path
:param str token: authentication token
:param str method: h... | Check if API request is authorized
:param str path: API path
:param str token: authentication token
:param str method: http method
:return: auth outcome
| is_request_authorized | python | Yelp/paasta | paasta_tools/api/tweens/auth.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/api/tweens/auth.py | Apache-2.0 |
def cprofile_tween_factory(handler, registry):
"""Tween for profiling API requests and sending them to scribe.
yelp_profiling does define a tween, but it is designed more for PaaSTA
services. So, we need to define our own.
"""
def cprofile_tween(request):
if yelp_profiling is None:
... | Tween for profiling API requests and sending them to scribe.
yelp_profiling does define a tween, but it is designed more for PaaSTA
services. So, we need to define our own.
| cprofile_tween_factory | python | Yelp/paasta | paasta_tools/api/tweens/profiling.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/api/tweens/profiling.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.