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 set_autoscaling_override(request):
"""Set a temporary autoscaling override for a service/instance.
This endpoint creates or updates a ConfigMap entry with override information
including expiration time. The override will be applied by the autoscaler.
Required parameters:
- service: The service... | Set a temporary autoscaling override for a service/instance.
This endpoint creates or updates a ConfigMap entry with override information
including expiration time. The override will be applied by the autoscaler.
Required parameters:
- service: The service name
- instance: The instance name
- ... | set_autoscaling_override | python | Yelp/paasta | paasta_tools/api/views/autoscaler.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/api/views/autoscaler.py | Apache-2.0 |
def api_failure_response(exc, request):
"""Construct an HTTP response with an error status code. This happens when
the API service has to stop on a 'hard' error. In contrast, the API service
continues to produce results on a 'soft' error. It will place a 'message'
field in the output. Multiple 'soft' er... | Construct an HTTP response with an error status code. This happens when
the API service has to stop on a 'hard' error. In contrast, the API service
continues to produce results on a 'soft' error. It will place a 'message'
field in the output. Multiple 'soft' errors are concatenated in the same
'message'... | api_failure_response | python | Yelp/paasta | paasta_tools/api/views/exception.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/api/views/exception.py | Apache-2.0 |
def window_historical_load(historical_load, window_begin, window_end):
"""Filter historical_load down to just the datapoints lying between times window_begin and window_end, inclusive."""
filtered = []
for timestamp, value in historical_load:
if timestamp >= window_begin and timestamp <= window_end:... | Filter historical_load down to just the datapoints lying between times window_begin and window_end, inclusive. | window_historical_load | python | Yelp/paasta | paasta_tools/autoscaling/forecasting.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/autoscaling/forecasting.py | Apache-2.0 |
def moving_average_forecast_policy(
historical_load,
moving_average_window_seconds=DEFAULT_UWSGI_AUTOSCALING_MOVING_AVERAGE_WINDOW,
**kwargs,
):
"""Does a simple average of all historical load data points within the moving average window. Weights all data
points within the window equally."""
wi... | Does a simple average of all historical load data points within the moving average window. Weights all data
points within the window equally. | moving_average_forecast_policy | python | Yelp/paasta | paasta_tools/autoscaling/forecasting.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/autoscaling/forecasting.py | Apache-2.0 |
def linreg_forecast_policy(
historical_load,
linreg_window_seconds,
linreg_extrapolation_seconds,
linreg_default_slope=0,
**kwargs,
):
"""Does a linear regression on the load data within the last linreg_window_seconds. For every time delta in
linreg_extrapolation_seconds, forecasts the value... | Does a linear regression on the load data within the last linreg_window_seconds. For every time delta in
linreg_extrapolation_seconds, forecasts the value at that time delta from now, and returns the maximum of these
predicted values. (With linear extrapolation, it doesn't make sense to forecast at more than tw... | linreg_forecast_policy | python | Yelp/paasta | paasta_tools/autoscaling/forecasting.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/autoscaling/forecasting.py | Apache-2.0 |
def get_sso_auth_token(paasta_apis: bool = False) -> str:
"""Generate an authentication token for the calling user from the Single Sign On provider
:param bool paasta_apis: authenticate for PaaSTA APIs
"""
system_config = load_system_paasta_config()
client_id = (
system_config.get_api_auth_... | Generate an authentication token for the calling user from the Single Sign On provider
:param bool paasta_apis: authenticate for PaaSTA APIs
| get_sso_auth_token | python | Yelp/paasta | paasta_tools/cli/authentication.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/authentication.py | Apache-2.0 |
def load_method(module_name, method_name):
"""Return a function given a module and method name.
:param module_name: a string
:param method_name: a string
:return: a function
"""
module = __import__(module_name, fromlist=[method_name])
method = getattr(module, method_name)
return method | Return a function given a module and method name.
:param module_name: a string
:param method_name: a string
:return: a function
| load_method | python | Yelp/paasta | paasta_tools/cli/cli.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cli.py | Apache-2.0 |
def add_subparser(command, subparsers):
"""Given a command name, paasta_cmd, execute the add_subparser method
implemented in paasta_cmd.py.
Each paasta client command must implement a method called add_subparser.
This allows the client to dynamically add subparsers to its subparser, which
provides ... | Given a command name, paasta_cmd, execute the add_subparser method
implemented in paasta_cmd.py.
Each paasta client command must implement a method called add_subparser.
This allows the client to dynamically add subparsers to its subparser, which
provides the benefits of argcomplete/argparse but gets i... | add_subparser | python | Yelp/paasta | paasta_tools/cli/cli.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cli.py | Apache-2.0 |
def get_argparser(commands=None):
"""Create and return argument parser for a set of subcommands.
:param commands: Union[None, List[str]] If `commands` argument is `None`,
add full parsers for all subcommands, if `commands` is empty list -
add thin parsers for all subcommands, otherwise - add full parse... | Create and return argument parser for a set of subcommands.
:param commands: Union[None, List[str]] If `commands` argument is `None`,
add full parsers for all subcommands, if `commands` is empty list -
add thin parsers for all subcommands, otherwise - add full parsers for
subcommands in the argument.
... | get_argparser | python | Yelp/paasta | paasta_tools/cli/cli.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cli.py | Apache-2.0 |
def parse_args(argv):
"""Initialize autocompletion and configure the argument parser.
:return: an argparse.Namespace object mapping parameter names to the inputs
from sys.argv
"""
parser = get_argparser(commands=[])
argcomplete.autocomplete(parser)
args, _ = parser.parse_known_arg... | Initialize autocompletion and configure the argument parser.
:return: an argparse.Namespace object mapping parameter names to the inputs
from sys.argv
| parse_args | python | Yelp/paasta | paasta_tools/cli/cli.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cli.py | Apache-2.0 |
def main(argv=None):
"""Perform a paasta call. Read args from sys.argv and pass parsed args onto
appropriate command in paasta_cli/cmds directory.
Ensure we kill any child pids before we quit
"""
logging.basicConfig()
warnings.filterwarnings("ignore", category=DeprecationWarning)
# if we a... | Perform a paasta call. Read args from sys.argv and pass parsed args onto
appropriate command in paasta_cli/cmds directory.
Ensure we kill any child pids before we quit
| main | python | Yelp/paasta | paasta_tools/cli/cli.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cli.py | Apache-2.0 |
def make_copyfile_symlink_aware():
"""The reasoning behind this monkeypatch is that cookiecutter doesn't
respect symlinks at all, and at Yelp we use symlinks to reduce duplication
in the soa configs. Maybe cookie-cutter will accept a symlink-aware PR?
"""
orig_copyfile = shutil.copyfile
orig_cop... | The reasoning behind this monkeypatch is that cookiecutter doesn't
respect symlinks at all, and at Yelp we use symlinks to reduce duplication
in the soa configs. Maybe cookie-cutter will accept a symlink-aware PR?
| make_copyfile_symlink_aware | python | Yelp/paasta | paasta_tools/cli/fsm_cmd.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/fsm_cmd.py | Apache-2.0 |
def is_file_in_dir(file_name, path):
"""Recursively search path for file_name.
:param file_name: a string of a file name to find
:param path: a string path
:param file_ext: a string of a file extension
:return: a boolean
"""
for root, dirnames, filenames in os.walk(path):
for filena... | Recursively search path for file_name.
:param file_name: a string of a file name to find
:param path: a string path
:param file_ext: a string of a file extension
:return: a boolean
| is_file_in_dir | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def validate_service_name(service, soa_dir=DEFAULT_SOA_DIR):
"""Determine whether directory named service exists in the provided soa_dir
:param service: a string of the name of the service you wish to check exists
:param soa_dir: directory to look for service names
:return : boolean True
:raises: No... | Determine whether directory named service exists in the provided soa_dir
:param service: a string of the name of the service you wish to check exists
:param soa_dir: directory to look for service names
:return : boolean True
:raises: NoSuchService exception
| validate_service_name | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def list_paasta_services(soa_dir: str = DEFAULT_SOA_DIR):
"""Returns a sorted list of services that happen to have at
least one service.instance, which indicates it is on PaaSTA
"""
the_list = []
for service in list_services(soa_dir):
if list_all_instances_for_service(service, soa_dir=soa_di... | Returns a sorted list of services that happen to have at
least one service.instance, which indicates it is on PaaSTA
| list_paasta_services | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def list_service_instances(soa_dir: str = DEFAULT_SOA_DIR):
"""Returns a sorted list of service<SPACER>instance names"""
the_list = []
for service in list_services(soa_dir):
for instance in list_all_instances_for_service(
service=service, soa_dir=soa_dir
):
the_list.a... | Returns a sorted list of service<SPACER>instance names | list_service_instances | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def list_instances(**kwargs):
"""Returns a sorted list of all possible instance names
for tab completion. We try to guess what service you might be
operating on, otherwise we just provide *all* of them
"""
all_instances: Set[str] = set()
service = guess_service_name()
try:
validate_s... | Returns a sorted list of all possible instance names
for tab completion. We try to guess what service you might be
operating on, otherwise we just provide *all* of them
| list_instances | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def calculate_remote_masters(
cluster: str, system_paasta_config: SystemPaastaConfig
) -> Tuple[List[str], str]:
"""Given a cluster, do a DNS lookup of that cluster (which
happens to point, eventually, to the Mesos masters in that cluster).
Return IPs of those Mesos masters.
"""
cluster_fqdn = ... | Given a cluster, do a DNS lookup of that cluster (which
happens to point, eventually, to the Mesos masters in that cluster).
Return IPs of those Mesos masters.
| calculate_remote_masters | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def check_ssh_on_master(master, timeout=10):
"""Given a master, attempt to ssh to the master and run a simple command
with sudo to verify that ssh and sudo work properly. Return a tuple of the
success status (True or False) and any output from attempting the check.
"""
check_command = "ssh -A -n -o ... | Given a master, attempt to ssh to the master and run a simple command
with sudo to verify that ssh and sudo work properly. Return a tuple of the
success status (True or False) and any output from attempting the check.
| check_ssh_on_master | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def run_on_master(
cluster,
system_paasta_config,
cmd_parts,
timeout=None,
err_code=-1,
graceful_exit=False,
stdin=None,
):
"""Find connectable master for :cluster: and :system_paasta_config: args and
invoke command from :cmd_parts:, wrapping it in ssh call.
:returns (exit code,... | Find connectable master for :cluster: and :system_paasta_config: args and
invoke command from :cmd_parts:, wrapping it in ssh call.
:returns (exit code, output)
:param cluster: cluster to find master in
:param system_paasta_config: system configuration to lookup master data
:param cmd_parts: passe... | run_on_master | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def figure_out_service_name(args, soa_dir=DEFAULT_SOA_DIR):
"""Figures out and validates the input service name"""
service = args.service or guess_service_name()
try:
validate_service_name(service, soa_dir=soa_dir)
except NoSuchService as service_not_found:
print(service_not_found)
... | Figures out and validates the input service name | figure_out_service_name | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def get_jenkins_build_output_url():
"""Returns the URL for Jenkins job's output.
Returns None if it's not available.
"""
build_output = os.environ.get("BUILD_URL")
if build_output:
build_output = build_output + "console"
return build_output | Returns the URL for Jenkins job's output.
Returns None if it's not available.
| get_jenkins_build_output_url | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def get_instance_config(
service: str,
instance: str,
cluster: str,
soa_dir: str = DEFAULT_SOA_DIR,
load_deployments: bool = False,
instance_type: Optional[str] = None,
) -> InstanceConfig:
"""Returns the InstanceConfig object for whatever type of instance
it is. (kubernetes)"""
if i... | Returns the InstanceConfig object for whatever type of instance
it is. (kubernetes) | get_instance_config | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def extract_tags(paasta_tag: str) -> Mapping[str, str]:
"""Returns a dictionary containing information from a git tag"""
regex = r"^refs/tags/(?:paasta-){1,2}(?P<deploy_group>[a-zA-Z0-9._-]+)(?:\+(?P<image_version>.*)){0,1}-(?P<tstamp>\d{8}T\d{6})-(?P<tag>.*?)$"
regex_match = re.match(regex, paasta_tag)
... | Returns a dictionary containing information from a git tag | extract_tags | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def validate_given_deploy_groups(
all_deploy_groups: Collection[str], args_deploy_groups: Collection[str]
) -> Tuple[Set[str], Set[str]]:
"""Given two lists of deploy groups, return the intersection and difference between them.
:param all_deploy_groups: instances actually belonging to a service
:param ... | Given two lists of deploy groups, return the intersection and difference between them.
:param all_deploy_groups: instances actually belonging to a service
:param args_deploy_groups: the desired instances
:returns: a tuple with (common, difference) indicating deploy groups common in both
lists and t... | validate_given_deploy_groups | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def pick_random_port(service_name):
"""Return a random port.
Tries to return the same port for the same service each time, when
possible.
"""
hash_key = f"{service_name},{getpass.getuser()}".encode("utf8")
hash_number = int(hashlib.sha1(hash_key).hexdigest(), 16)
preferred_port = 33000 + (h... | Return a random port.
Tries to return the same port for the same service each time, when
possible.
| pick_random_port | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def trigger_deploys(
service: str,
system_config: Optional["SystemPaastaConfig"] = None,
) -> None:
"""Connects to the deploymentsd watcher on sysgit, which is an extremely simple
service that listens for a service string and then generates a service deployment"""
logline = f"Notifying soa-configs p... | Connects to the deploymentsd watcher on sysgit, which is an extremely simple
service that listens for a service string and then generates a service deployment | trigger_deploys | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def verify_instances(
args_instances: str,
service: str,
clusters: Sequence[str],
soa_dir: str = DEFAULT_SOA_DIR,
) -> Sequence[str]:
"""Verify that a list of instances specified by user is correct for this service.
:param args_instances: a list of instances.
:param service: the service nam... | Verify that a list of instances specified by user is correct for this service.
:param args_instances: a list of instances.
:param service: the service name
:param cluster: a list of clusters
:returns: a list of instances specified in args_instances without any exclusions.
| verify_instances | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def run_interactive_cli(
cmd: str, shell: str = "/bin/bash", term: str = "xterm-256color"
):
"""Runs interactive command in a pseudo terminal, handling terminal size management
:param str cmd: shell command
:param str shell: shell utility to use as wrapper
:param str term: terminal type
"""
... | Runs interactive command in a pseudo terminal, handling terminal size management
:param str cmd: shell command
:param str shell: shell utility to use as wrapper
:param str term: terminal type
| run_interactive_cli | python | Yelp/paasta | paasta_tools/cli/utils.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/utils.py | Apache-2.0 |
def parse_duration_to_seconds(duration: str) -> Optional[int]:
"""Parse a duration string like '3h' or '30m' into seconds.
Args:
duration_str: A string representing a duration (e.g., "3h", "30m", "1d")
Returns:
The duration in seconds, or None if parsing failed
"""
if not duration:... | Parse a duration string like '3h' or '30m' into seconds.
Args:
duration_str: A string representing a duration (e.g., "3h", "30m", "1d")
Returns:
The duration in seconds, or None if parsing failed
| parse_duration_to_seconds | python | Yelp/paasta | paasta_tools/cli/cmds/autoscale.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/autoscale.py | Apache-2.0 |
def deploy_check(service_path):
"""Check whether deploy.yaml exists in service directory. Prints success or
error message.
:param service_path: path to a directory containing deploy.yaml"""
if is_file_in_dir("deploy.yaml", service_path):
print(PaastaCheckMessages.DEPLOY_YAML_FOUND)
else:
... | Check whether deploy.yaml exists in service directory. Prints success or
error message.
:param service_path: path to a directory containing deploy.yaml | deploy_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def docker_check():
"""Check whether Dockerfile exists in service directory, and is valid.
Prints suitable message depending on outcome"""
docker_file_path = is_file_in_dir("Dockerfile", os.getcwd())
if docker_file_path:
print(PaastaCheckMessages.DOCKERFILE_FOUND)
else:
print(PaastaC... | Check whether Dockerfile exists in service directory, and is valid.
Prints suitable message depending on outcome | docker_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def makefile_responds_to(target):
"""Runs `make --question <target>` to detect if a makefile responds to the
specified target."""
# According to http://www.gnu.org/software/make/manual/make.html#index-exit-status-of-make,
# 0 means OK, 1 means the target is not up to date, and 2 means error
returnco... | Runs `make --question <target>` to detect if a makefile responds to the
specified target. | makefile_responds_to | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def makefile_check():
"""Detects if you have a makefile and runs some sanity tests against
it to ensure it is paasta-ready"""
makefile_path = is_file_in_dir("Makefile", os.getcwd())
if makefile_path:
print(PaastaCheckMessages.MAKEFILE_FOUND)
if makefile_has_a_tab(makefile_path):
... | Detects if you have a makefile and runs some sanity tests against
it to ensure it is paasta-ready | makefile_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def get_deploy_groups_used_by_framework(instance_type, service, soa_dir):
"""This is a kind of funny function that gets all the instances for specified
service and framework, and massages it into a form that matches up with what
deploy.yaml's steps look like. This is only so we can compare it 1-1
with w... | This is a kind of funny function that gets all the instances for specified
service and framework, and massages it into a form that matches up with what
deploy.yaml's steps look like. This is only so we can compare it 1-1
with what deploy.yaml has for linting.
:param instance_type: one of the entries in... | get_deploy_groups_used_by_framework | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def deployments_check(service, soa_dir):
"""Checks for consistency between deploy.yaml and the kubernetes/etc yamls"""
the_return = True
pipeline_deploy_groups = get_pipeline_deploy_groups(
service=service, soa_dir=soa_dir
)
framework_deploy_groups = {}
in_deploy_not_frameworks = set(pi... | Checks for consistency between deploy.yaml and the kubernetes/etc yamls | deployments_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def sensu_check(service, service_path, soa_dir):
"""Check whether monitoring.yaml exists in service directory,
and that the team name is declared.
:param service: name of service currently being examined
:param service_path: path to location of monitoring.yaml file"""
if is_file_in_dir("monitoring.... | Check whether monitoring.yaml exists in service directory,
and that the team name is declared.
:param service: name of service currently being examined
:param service_path: path to location of monitoring.yaml file | sensu_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def service_dir_check(service, soa_dir):
"""Check whether directory service exists in /nail/etc/services
:param service: string of service name we wish to inspect
"""
try:
validate_service_name(service, soa_dir)
print(PaastaCheckMessages.service_dir_found(service, soa_dir))
except No... | Check whether directory service exists in /nail/etc/services
:param service: string of service name we wish to inspect
| service_dir_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def smartstack_check(service, service_path, soa_dir):
"""Check whether smartstack.yaml exists in service directory, and the proxy
ports are declared. Print appropriate message depending on outcome.
:param service: name of service currently being examined
:param service_path: path to location of smarts... | Check whether smartstack.yaml exists in service directory, and the proxy
ports are declared. Print appropriate message depending on outcome.
:param service: name of service currently being examined
:param service_path: path to location of smartstack.yaml file | smartstack_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def paasta_check(args):
"""Analyze the service in the PWD to determine if it is paasta ready
:param args: argparse.Namespace obj created from sys.args by cli"""
soa_dir = args.yelpsoa_config_root
service = figure_out_service_name(args, soa_dir)
service_path = os.path.join(soa_dir, service)
serv... | Analyze the service in the PWD to determine if it is paasta ready
:param args: argparse.Namespace obj created from sys.args by cli | paasta_check | python | Yelp/paasta | paasta_tools/cli/cmds/check.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/check.py | Apache-2.0 |
def paasta_list(args):
"""Print a list of Yelp services currently running
:param args: argparse.Namespace obj created from sys.args by cli"""
if args.print_instances:
services = list_service_instances(args.soa_dir)
elif args.all:
services = list_services(args.soa_dir)
else:
s... | Print a list of Yelp services currently running
:param args: argparse.Namespace obj created from sys.args by cli | paasta_list | python | Yelp/paasta | paasta_tools/cli/cmds/list.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/list.py | Apache-2.0 |
def perform_http_healthcheck(url, timeout):
"""Returns true if healthcheck on url succeeds, false otherwise
:param url: the healthcheck url
:param timeout: timeout in seconds
:returns: True if healthcheck succeeds within number of seconds specified by timeout, false otherwise
"""
try:
w... | Returns true if healthcheck on url succeeds, false otherwise
:param url: the healthcheck url
:param timeout: timeout in seconds
:returns: True if healthcheck succeeds within number of seconds specified by timeout, false otherwise
| perform_http_healthcheck | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def perform_tcp_healthcheck(url, timeout):
"""Returns true if successfully connects to host and port, false otherwise
:param url: the healthcheck url (in the form tcp://host:port)
:param timeout: timeout in seconds
:returns: True if healthcheck succeeds within number of seconds specified by timeout, fa... | Returns true if successfully connects to host and port, false otherwise
:param url: the healthcheck url (in the form tcp://host:port)
:param timeout: timeout in seconds
:returns: True if healthcheck succeeds within number of seconds specified by timeout, false otherwise
| perform_tcp_healthcheck | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def perform_cmd_healthcheck(docker_client, container_id, command, timeout):
"""Returns true if return code of command is 0 when executed inside container, false otherwise
:param docker_client: Docker client object
:param container_id: Docker container id
:param command: command to execute
:param ti... | Returns true if return code of command is 0 when executed inside container, false otherwise
:param docker_client: Docker client object
:param container_id: Docker container id
:param command: command to execute
:param timeout: timeout in seconds
:returns: True if command exits with return code 0, f... | perform_cmd_healthcheck | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def run_healthcheck_on_container(
docker_client, container_id, healthcheck_mode, healthcheck_data, timeout
):
"""Performs healthcheck on a container
:param container_id: Docker container id
:param healthcheck_mode: one of 'http', 'https', 'tcp', or 'cmd'
:param healthcheck_data: a URL when healthch... | Performs healthcheck on a container
:param container_id: Docker container id
:param healthcheck_mode: one of 'http', 'https', 'tcp', or 'cmd'
:param healthcheck_data: a URL when healthcheck_mode is 'http[s]' or 'tcp', a command if healthcheck_mode is 'cmd'
:param timeout: timeout in seconds for individ... | run_healthcheck_on_container | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def simulate_healthcheck_on_service(
instance_config,
docker_client,
container_id,
healthcheck_mode,
healthcheck_data,
healthcheck_enabled,
):
"""Simulates Marathon-style healthcheck on given service if healthcheck is enabled
:param instance_config: service manifest
:param docker_cl... | Simulates Marathon-style healthcheck on given service if healthcheck is enabled
:param instance_config: service manifest
:param docker_client: Docker client object
:param container_id: Docker container id
:param healthcheck_data: tuple url to healthcheck
:param healthcheck_enabled: boolean
:ret... | simulate_healthcheck_on_service | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def docker_pull_image(docker_url):
"""Pull an image via ``docker pull``. Uses the actual pull command instead of the python
bindings due to the docker auth/registry transition. Once we are past Docker 1.6
we can use better credential management, but for now this function assumes the
user running the com... | Pull an image via ``docker pull``. Uses the actual pull command instead of the python
bindings due to the docker auth/registry transition. Once we are past Docker 1.6
we can use better credential management, but for now this function assumes the
user running the command has already been authorized for the r... | docker_pull_image | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def get_container_id(docker_client, container_name):
"""Use 'docker_client' to find the container we started, identifiable by
its 'container_name'. If we can't find the id, raise
LostContainerException.
"""
containers = docker_client.containers(all=False)
for container in containers:
if ... | Use 'docker_client' to find the container we started, identifiable by
its 'container_name'. If we can't find the id, raise
LostContainerException.
| get_container_id | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def get_local_run_environment_vars(instance_config, port0, framework):
"""Returns a dictionary of environment variables to simulate what would be available to
a paasta service running in a container"""
hostname = socket.getfqdn()
docker_image = instance_config.get_docker_image()
if docker_image == "... | Returns a dictionary of environment variables to simulate what would be available to
a paasta service running in a container | get_local_run_environment_vars | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def assume_aws_role(
instance_config: InstanceConfig,
service: str,
assume_role_arn: str,
assume_pod_identity: bool,
use_okta_role: bool,
aws_account: str,
) -> AWSSessionCreds:
"""Runs AWS cli to assume into the correct role, then extract and return the ENV variables from that session"""
... | Runs AWS cli to assume into the correct role, then extract and return the ENV variables from that session | assume_aws_role | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def run_docker_container(
docker_client,
service,
instance,
docker_url,
volumes,
interactive,
command,
healthcheck,
healthcheck_only,
user_port,
instance_config,
secret_provider_name,
soa_dir=DEFAULT_SOA_DIR,
dry_run=False,
json_dict=False,
framework=None,... | docker-py has issues running a container with a TTY attached, so for
consistency we execute 'docker run' directly in both interactive and
non-interactive modes.
In non-interactive mode when the run is complete, stop the container and
remove it (with docker-py).
| run_docker_container | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def format_command_for_type(command, instance_type, date):
"""
Given an instance_type, return a function that appropriately formats
the command to be run.
"""
if instance_type == "tron":
interpolated_command = parse_time_variables(command, date)
return interpolated_command
else:
... |
Given an instance_type, return a function that appropriately formats
the command to be run.
| format_command_for_type | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def configure_and_run_docker_container(
docker_client,
docker_url,
docker_sha,
service,
instance,
cluster,
system_paasta_config,
args,
assume_role_aws_account,
pull_image=False,
dry_run=False,
):
"""
Run Docker container by image hash with args set in command line.
... |
Run Docker container by image hash with args set in command line.
Function prints the output of run command in stdout.
| configure_and_run_docker_container | python | Yelp/paasta | paasta_tools/cli/cmds/local_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/local_run.py | Apache-2.0 |
def build_component_descriptions(components: Mapping[str, Mapping[str, Any]]) -> str:
"""Returns a colored description string for every log component
based on its help attribute"""
output = []
for k, v in components.items():
output.append(" {}: {}".format(v["color"](k), v["help"]))
return... | Returns a colored description string for every log component
based on its help attribute | build_component_descriptions | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def check_timestamp_in_range(
timestamp: datetime.datetime,
start_time: datetime.datetime,
end_time: datetime.datetime,
) -> bool:
"""A convenience function to check if a datetime.datetime timestamp is within the given start and end times,
returns true if start_time or end_time is None
:param t... | A convenience function to check if a datetime.datetime timestamp is within the given start and end times,
returns true if start_time or end_time is None
:param timestamp: The timestamp to check
:param start_time: The start of the interval
:param end_time: The end of the interval
:return: True if ti... | check_timestamp_in_range | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def paasta_log_line_passes_filter(
line: str,
levels: Sequence[str],
service: str,
components: Iterable[str],
clusters: Sequence[str],
instances: List[str],
pods: Iterable[str] = None,
start_time: datetime.datetime = None,
end_time: datetime.datetime = None,
) -> bool:
"""Given a... | Given a (JSON-formatted) log line, return True if the line should be
displayed given the provided levels, components, and clusters; return False
otherwise.
NOTE: Pods are optional as services that use Mesos do not operate with pods.
| paasta_log_line_passes_filter | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def extract_utc_timestamp_from_log_line(line: str) -> datetime.datetime:
"""
Extracts the timestamp from a log line of the format "<timestamp> <other data>" and returns a UTC datetime object
or None if it could not parse the line
"""
# Extract ISO 8601 date per http://www.pelagodesign.com/blog/2009/... |
Extracts the timestamp from a log line of the format "<timestamp> <other data>" and returns a UTC datetime object
or None if it could not parse the line
| extract_utc_timestamp_from_log_line | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def print_log(
line: str,
requested_levels: Sequence[str],
raw_mode: bool = False,
strip_headers: bool = False,
) -> None:
"""Mostly a stub to ease testing. Eventually this may do some formatting or
something.
"""
if raw_mode:
# suppress trailing newline since scribereader alread... | Mostly a stub to ease testing. Eventually this may do some formatting or
something.
| print_log | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def prettify_timestamp(timestamp: datetime.datetime) -> str:
"""Returns more human-friendly form of 'timestamp' without microseconds and
in local time.
"""
dt = isodate.parse_datetime(timestamp)
pretty_timestamp = datetime_from_utc_to_local(dt)
return pretty_timestamp.strftime("%Y-%m-%d %H:%M:%S... | Returns more human-friendly form of 'timestamp' without microseconds and
in local time.
| prettify_timestamp | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def prettify_log_line(
line: str, requested_levels: Sequence[str], strip_headers: bool
) -> str:
"""Given a line from the log, which is expected to be JSON and have all the
things we expect, return a pretty formatted string containing relevant values.
"""
try:
parsed_line = json.loads(line)
... | Given a line from the log, which is expected to be JSON and have all the
things we expect, return a pretty formatted string containing relevant values.
| prettify_log_line | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def register_log_reader(name):
"""Returns a decorator that registers a log reader class at a given name
so get_log_reader_classes can find it."""
def outer(log_reader_class):
_log_reader_classes[name] = log_reader_class
return log_reader_class
return outer | Returns a decorator that registers a log reader class at a given name
so get_log_reader_classes can find it. | register_log_reader | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def run_code_over_scribe_envs(
self,
clusters: Sequence[str],
components: Iterable[str],
callback: Callable[..., None],
) -> None:
"""Iterates over the scribe environments for a given set of clusters and components, executing
functions for each component
:par... | Iterates over the scribe environments for a given set of clusters and components, executing
functions for each component
:param clusters: The set of clusters
:param components: The set of components
:param callback: The callback function. Gets called with (component_name, stream_info, s... | run_code_over_scribe_envs | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def tail_logs(
self,
service: str,
levels: Sequence[str],
components: Iterable[str],
clusters: Sequence[str],
instances: List[str],
pods: Iterable[str] = None,
raw_mode: bool = False,
strip_headers: bool = False,
) -> None:
"""Sergeant ... | Sergeant function for spawning off all the right log tailing functions.
NOTE: This function spawns concurrent processes and doesn't necessarily
worry about cleaning them up! That's because we expect to just exit the
main process when this function returns (as main() does). Someone calling
... | tail_logs | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def scribe_tail(
self,
scribe_env: str,
stream_name: str,
service: str,
levels: Sequence[str],
components: Iterable[str],
clusters: Sequence[str],
instances: List[str],
pods: Iterable[str],
queue: Queue,
filter_fn: Callable,
... | Creates a scribetailer for a particular environment.
When it encounters a line that it should report, it sticks it into the
provided queue.
This code is designed to run in a thread as spawned by tail_paasta_logs().
| scribe_tail | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def determine_scribereader_envs(
self, components: Iterable[str], cluster: str
) -> Set[str]:
"""Returns a list of environments that scribereader needs to connect
to based on a given list of components and the cluster involved.
Some components are in certain environments, regardless... | Returns a list of environments that scribereader needs to connect
to based on a given list of components and the cluster involved.
Some components are in certain environments, regardless of the cluster.
Some clusters do not match up with the scribe environment names, so
we figure that o... | determine_scribereader_envs | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def cluster_to_scribe_env(self, cluster: str) -> str:
"""Looks up the particular scribe env associated with a given paasta cluster.
Scribe has its own "environment" key, which doesn't always map 1:1 with our
cluster names, so we have to maintain a manual mapping.
This mapping is deploy... | Looks up the particular scribe env associated with a given paasta cluster.
Scribe has its own "environment" key, which doesn't always map 1:1 with our
cluster names, so we have to maintain a manual mapping.
This mapping is deployed as a config file via puppet as part of the public
conf... | cluster_to_scribe_env | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def scribe_env_to_locations(scribe_env) -> Mapping[str, Any]:
"""Converts a scribe environment to a dictionary of locations. The
return value is meant to be used as kwargs for `scribereader.get_tail_host_and_port`.
"""
locations = {"ecosystem": None, "region": None, "superregion": None}
if scribe_en... | Converts a scribe environment to a dictionary of locations. The
return value is meant to be used as kwargs for `scribereader.get_tail_host_and_port`.
| scribe_env_to_locations | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def generate_start_end_time(
from_string: str = "30m", to_string: str = None
) -> Tuple[datetime.datetime, datetime.datetime]:
"""Parses the --from and --to command line arguments to create python
datetime objects representing the start and end times for log retrieval
:param from_string: The --from arg... | Parses the --from and --to command line arguments to create python
datetime objects representing the start and end times for log retrieval
:param from_string: The --from argument, defaults to 30 minutes
:param to_string: The --to argument, defaults to the time right now
:return: A tuple containing star... | generate_start_end_time | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def paasta_logs(args: argparse.Namespace) -> int:
"""Print the logs for as Paasta service.
:param args: argparse.Namespace obj created from sys.args by cli"""
soa_dir = args.soa_dir
service = figure_out_service_name(args, soa_dir)
clusters = args.cluster
if (
args.cluster is None
... | Print the logs for as Paasta service.
:param args: argparse.Namespace obj created from sys.args by cli | paasta_logs | python | Yelp/paasta | paasta_tools/cli/cmds/logs.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/logs.py | Apache-2.0 |
def can_run_metric_watcher_threads(
service: str,
soa_dir: str,
) -> bool:
"""
Cannot run slo and metric watcher threads together for now.
SLO Watcher Threads take precedence over metric watcher threads.
Metric Watcher Threads can run if there are no SLOs available.
"""
slo_files = get_f... |
Cannot run slo and metric watcher threads together for now.
SLO Watcher Threads take precedence over metric watcher threads.
Metric Watcher Threads can run if there are no SLOs available.
| can_run_metric_watcher_threads | python | Yelp/paasta | paasta_tools/cli/cmds/mark_for_deployment.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/mark_for_deployment.py | Apache-2.0 |
def get_slack_channel(self) -> str:
"""Safely get some slack channel to post to. Defaults to ``DEFAULT_SLACK_CHANNEL``.
Currently only uses the first slack channel available, and doesn't support
multi-channel notifications."""
if self.deploy_info.get("slack_notify", True):
tr... | Safely get some slack channel to post to. Defaults to ``DEFAULT_SLACK_CHANNEL``.
Currently only uses the first slack channel available, and doesn't support
multi-channel notifications. | get_slack_channel | python | Yelp/paasta | paasta_tools/cli/cmds/mark_for_deployment.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/mark_for_deployment.py | Apache-2.0 |
def paasta_pause_service_autoscaler(args):
"""With a given cluster and duration, pauses the paasta service autoscaler
in that cluster for duration minutes"""
if args.duration > MAX_PAUSE_DURATION:
if not args.force:
print(
"Specified duration: {d} longer than max: {m}".fo... | With a given cluster and duration, pauses the paasta service autoscaler
in that cluster for duration minutes | paasta_pause_service_autoscaler | python | Yelp/paasta | paasta_tools/cli/cmds/pause_service_autoscaler.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/pause_service_autoscaler.py | Apache-2.0 |
def is_docker_image_already_in_registry(service: str, soa_dir: str, sha: str, image_version: Optional[str] = None) -> bool: # type: ignore
"""Verifies that docker image exists in the paasta registry.
:param service: name of the service
:param sha: git sha
:returns: True, False or raises requests.excep... | Verifies that docker image exists in the paasta registry.
:param service: name of the service
:param sha: git sha
:returns: True, False or raises requests.exceptions.RequestException
| is_docker_image_already_in_registry | python | Yelp/paasta | paasta_tools/cli/cmds/push_to_registry.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/push_to_registry.py | Apache-2.0 |
def get_versions_for_service(
service: str, deploy_groups: Collection[str], soa_dir: str
) -> Mapping[DeploymentVersion, Tuple[str, str]]:
"""Returns a dictionary of 2-tuples of the form (timestamp, deploy_group) for each version tuple of (deploy sha, image_version)"""
if service is None:
return {}
... | Returns a dictionary of 2-tuples of the form (timestamp, deploy_group) for each version tuple of (deploy sha, image_version) | get_versions_for_service | python | Yelp/paasta | paasta_tools/cli/cmds/rollback.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/rollback.py | Apache-2.0 |
def paasta_rollback(args: argparse.Namespace) -> int:
"""Call mark_for_deployment with rollback parameters
:param args: contains all the arguments passed onto the script: service,
deploy groups and sha. These arguments will be verified and passed onto
mark_for_deployment.
"""
soa_dir = args.soa... | Call mark_for_deployment with rollback parameters
:param args: contains all the arguments passed onto the script: service,
deploy groups and sha. These arguments will be verified and passed onto
mark_for_deployment.
| paasta_rollback | python | Yelp/paasta | paasta_tools/cli/cmds/rollback.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/rollback.py | Apache-2.0 |
def _add_and_update_args(parser: argparse.ArgumentParser):
"""common args for `add` and `update`."""
parser.add_argument(
"-p",
"--plain-text",
required=False,
type=str,
help="Optionally specify the secret as a command line argument",
)
parser.add_argument(
... | common args for `add` and `update`. | _add_and_update_args | python | Yelp/paasta | paasta_tools/cli/cmds/secret.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/secret.py | Apache-2.0 |
def get_docker_image(
args: argparse.Namespace, instance_config: InstanceConfig
) -> Optional[str]:
"""
Since the Docker image digest used to launch the Spark cluster is obtained by inspecting local
Docker images, we need to ensure that the Docker image exists locally or is pulled in all scenarios.
... |
Since the Docker image digest used to launch the Spark cluster is obtained by inspecting local
Docker images, we need to ensure that the Docker image exists locally or is pulled in all scenarios.
| get_docker_image | python | Yelp/paasta | paasta_tools/cli/cmds/spark_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/spark_run.py | Apache-2.0 |
def get_spark_env(
args: argparse.Namespace,
spark_conf_str: str,
aws_creds: Tuple[Optional[str], Optional[str], Optional[str]],
ui_port: str,
system_paasta_config: SystemPaastaConfig,
) -> Dict[str, str]:
"""Create the env config dict to configure on the docker container"""
spark_env = {}
... | Create the env config dict to configure on the docker container | get_spark_env | python | Yelp/paasta | paasta_tools/cli/cmds/spark_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/spark_run.py | Apache-2.0 |
def _calculate_docker_shared_memory_size(shm_size: Optional[str]) -> str:
"""In Order of preference:
1. Argument: --docker-shm-size
3. Default
"""
if shm_size:
return shm_size
return DEFAULT_DOCKER_SHM_SIZE | In Order of preference:
1. Argument: --docker-shm-size
3. Default
| _calculate_docker_shared_memory_size | python | Yelp/paasta | paasta_tools/cli/cmds/spark_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/spark_run.py | Apache-2.0 |
def build_and_push_docker_image(args: argparse.Namespace) -> Optional[str]:
"""
Build an image if the default Spark service image is not preferred.
The image needs to be pushed to a registry for the Spark executors
to pull.
"""
if not makefile_responds_to("cook-image"):
print(
... |
Build an image if the default Spark service image is not preferred.
The image needs to be pushed to a registry for the Spark executors
to pull.
| build_and_push_docker_image | python | Yelp/paasta | paasta_tools/cli/cmds/spark_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/spark_run.py | Apache-2.0 |
def update_args_from_tronfig(args: argparse.Namespace) -> Optional[Dict[str, str]]:
"""
Load and check the following config fields from the provided Tronfig.
- executor
- pool
- iam_role
- iam_role_provider
- force_spark_resource_configs
- max_runtime
- command
- ... |
Load and check the following config fields from the provided Tronfig.
- executor
- pool
- iam_role
- iam_role_provider
- force_spark_resource_configs
- max_runtime
- command
- env
- spark_args
Returns: environment variables dictionary or None if failed.
... | update_args_from_tronfig | python | Yelp/paasta | paasta_tools/cli/cmds/spark_run.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/spark_run.py | Apache-2.0 |
def make_mutate_refs_func(service_config, force_bounce, desired_state):
"""Create a function that will inform send_pack that we want to create tags
corresponding to the set of branches passed, with the given force_bounce
and desired_state parameters. These tags will point at the current tip of
the branc... | Create a function that will inform send_pack that we want to create tags
corresponding to the set of branches passed, with the given force_bounce
and desired_state parameters. These tags will point at the current tip of
the branch they associate with.
dulwich's send_pack wants a function that takes a d... | make_mutate_refs_func | python | Yelp/paasta | paasta_tools/cli/cmds/start_stop_restart.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/start_stop_restart.py | Apache-2.0 |
def paasta_start_or_stop(args, desired_state):
"""Requests a change of state to start or stop given branches of a service."""
soa_dir = args.soa_dir
pargs = apply_args_filters(args)
if len(pargs) == 0:
return 1
affected_services = {
s for service_list in pargs.values() for s in ser... | Requests a change of state to start or stop given branches of a service. | paasta_start_or_stop | python | Yelp/paasta | paasta_tools/cli/cmds/start_stop_restart.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/start_stop_restart.py | Apache-2.0 |
def get_actual_deployments(
service: str, soa_dir: str
) -> Mapping[str, DeploymentVersion]:
"""Given a service, return a dict of instances->DeploymentVersions"""
config_loader = PaastaServiceConfigLoader(service=service, soa_dir=soa_dir)
clusters = list_clusters(service=service, soa_dir=soa_dir)
ac... | Given a service, return a dict of instances->DeploymentVersions | get_actual_deployments | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def find_instance_types(status: Any) -> List[str]:
"""
find_instance_types finds the instance types from the status api response.
It iterates over all instance type registered in `INSTANCE_TYPE_WRITERS`.
:param status: paasta api status object
:return: the list of matching instance types
"""
... |
find_instance_types finds the instance types from the status api response.
It iterates over all instance type registered in `INSTANCE_TYPE_WRITERS`.
:param status: paasta api status object
:return: the list of matching instance types
| find_instance_types | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def report_status_for_cluster(
service: str,
cluster: str,
deploy_pipeline: Sequence[str],
actual_deployments: Mapping[str, DeploymentVersion],
instance_whitelist: Mapping[str, Type[InstanceConfig]],
system_paasta_config: SystemPaastaConfig,
lock: Lock,
verbose: int = 0,
new: bool = ... | With a given service and cluster, prints the status of the instances
in that cluster | report_status_for_cluster | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def report_invalid_whitelist_values(
whitelist: Iterable[str], items: Sequence[str], item_type: str
) -> str:
"""Warns the user if there are entries in ``whitelist`` which don't
correspond to any item in ``items``. Helps highlight typos.
"""
return_string = ""
bogus_entries = []
if whitelist... | Warns the user if there are entries in ``whitelist`` which don't
correspond to any item in ``items``. Helps highlight typos.
| report_invalid_whitelist_values | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def get_filters(
args,
) -> Sequence[Callable[[InstanceConfig], bool]]:
"""Figures out which filters to apply from an args object, and returns them
:param args: args object
:returns: list of functions that take an instance config and returns if the instance conf matches the filter
"""
filters =... | Figures out which filters to apply from an args object, and returns them
:param args: args object
:returns: list of functions that take an instance config and returns if the instance conf matches the filter
| get_filters | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def apply_args_filters(
args,
) -> Mapping[str, Mapping[str, Mapping[str, Type[InstanceConfig]]]]:
"""
Take an args object and returns the dict of cluster:service:instances
Currently, will filter by clusters, instances, services, and deploy_groups
If no instances are found, will print a message and ... |
Take an args object and returns the dict of cluster:service:instances
Currently, will filter by clusters, instances, services, and deploy_groups
If no instances are found, will print a message and try to find matching instances
for each service
:param args: args object containing attributes to fil... | apply_args_filters | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def paasta_status(args) -> int:
"""Print the status of a Yelp service running on PaaSTA.
:param args: argparse.Namespace obj created from sys.args by cli"""
soa_dir = args.soa_dir
system_paasta_config = load_system_paasta_config()
return_codes = [0]
lock = Lock()
tasks = []
clusters_ser... | Print the status of a Yelp service running on PaaSTA.
:param args: argparse.Namespace obj created from sys.args by cli | paasta_status | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def _backend_report(
normal_instance_count: int, up_backends: int, system_name: BackendType
) -> str:
"""Given that a service is in smartstack, this returns a human readable
report of the up backends"""
# TODO: Take into account a configurable threshold, PAASTA-1102
crit_threshold = 50
under_rep... | Given that a service is in smartstack, this returns a human readable
report of the up backends | _backend_report | python | Yelp/paasta | paasta_tools/cli/cmds/status.py | https://github.com/Yelp/paasta/blob/master/paasta_tools/cli/cmds/status.py | Apache-2.0 |
def get_schema_validator(file_type: str) -> Draft4Validator:
"""Get the correct schema to use for validation
:param file_type: what schema type should we validate against
"""
schema_path = f"schemas/{file_type}_schema.json"
autoscaling_path = "schemas/autoscaling_schema.json"
schema = pkgutil.g... | Get the correct schema to use for validation
:param file_type: what schema type should we validate against
| get_schema_validator | 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 validate_rollback_bounds(
config: Dict[str, List[ConditionConfig]], file_loc: str
) -> bool:
"""
Ensure that at least one of upper_bound or lower_bound is set (and set to non-null values)
"""
errors = []
for source, queries in config.items():
for query in queries:
if not... |
Ensure that at least one of upper_bound or lower_bound is set (and set to non-null values)
| validate_rollback_bounds | 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 validate_schema(file_path: str, file_type: str) -> bool:
"""Check if the specified config file has a valid schema
:param file_path: path to file to validate
:param file_type: what schema type should we validate against
"""
try:
validator = get_schema_validator(file_type)
except Exce... | Check if the specified config file has a valid schema
:param file_path: path to file to validate
:param file_type: what schema type should we validate against
| validate_schema | 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 validate_all_schemas(service_path: str) -> bool:
"""Finds all recognized config files in service directory,
and validates their schema.
:param service_path: path to location of configuration files
"""
path = os.path.join(service_path, "**/*.yaml")
returncode = True
for file_name in gl... | Finds all recognized config files in service directory,
and validates their schema.
:param service_path: path to location of configuration files
| validate_all_schemas | 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 check_service_path(service_path):
"""Check that the specified path exists and has yaml files
:param service_path: Path to directory that should contain yaml files
"""
if not service_path or not os.path.isdir(service_path):
print(
failure(
"%s is not a directory" ... | Check that the specified path exists and has yaml files
:param service_path: Path to directory that should contain yaml files
| check_service_path | 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_service_path(service, soa_dir):
"""Determine the path of the directory containing the conf files
:param service: Name of service
:param soa_dir: Directory containing soa configs for all services
"""
if service:
service_path = os.path.join(soa_dir, service)
else:
if soa_d... | Determine the path of the directory containing the conf files
:param service: Name of service
:param soa_dir: Directory containing soa configs for all services
| get_service_path | 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 path_to_soa_dir_service(service_path):
"""Split a service_path into its soa_dir and service name components"""
soa_dir = os.path.dirname(service_path)
service = os.path.basename(service_path)
return soa_dir, service | Split a service_path into its soa_dir and service name components | path_to_soa_dir_service | 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 validate_unique_instance_names(service_path):
"""Check that the service does not use the same instance name more than once"""
soa_dir, service = path_to_soa_dir_service(service_path)
check_passed = True
for cluster in list_clusters(service, soa_dir):
service_instances = get_service_instance... | Check that the service does not use the same instance name more than once | validate_unique_instance_names | 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 validate_autoscaling_configs(service_path: str) -> bool:
"""Validate new autoscaling configurations that are not validated by jsonschema for the service of interest.
:param service_path: Path to directory containing soa conf yaml files for service
"""
soa_dir, service = path_to_soa_dir_service(serv... | Validate new autoscaling configurations that are not validated by jsonschema for the service of interest.
:param service_path: Path to directory containing soa conf yaml files for service
| validate_autoscaling_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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.