paasta-tools 1.21.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k8s_itests/__init__.py +0 -0
- k8s_itests/test_autoscaling.py +23 -0
- k8s_itests/utils.py +38 -0
- paasta_tools/__init__.py +20 -0
- paasta_tools/adhoc_tools.py +142 -0
- paasta_tools/api/__init__.py +13 -0
- paasta_tools/api/api.py +330 -0
- paasta_tools/api/api_docs/swagger.json +2323 -0
- paasta_tools/api/client.py +106 -0
- paasta_tools/api/settings.py +33 -0
- paasta_tools/api/tweens/__init__.py +6 -0
- paasta_tools/api/tweens/auth.py +125 -0
- paasta_tools/api/tweens/profiling.py +108 -0
- paasta_tools/api/tweens/request_logger.py +124 -0
- paasta_tools/api/views/__init__.py +13 -0
- paasta_tools/api/views/autoscaler.py +100 -0
- paasta_tools/api/views/exception.py +45 -0
- paasta_tools/api/views/flink.py +73 -0
- paasta_tools/api/views/instance.py +395 -0
- paasta_tools/api/views/pause_autoscaler.py +71 -0
- paasta_tools/api/views/remote_run.py +113 -0
- paasta_tools/api/views/resources.py +76 -0
- paasta_tools/api/views/service.py +35 -0
- paasta_tools/api/views/version.py +25 -0
- paasta_tools/apply_external_resources.py +79 -0
- paasta_tools/async_utils.py +109 -0
- paasta_tools/autoscaling/__init__.py +0 -0
- paasta_tools/autoscaling/autoscaling_service_lib.py +57 -0
- paasta_tools/autoscaling/forecasting.py +106 -0
- paasta_tools/autoscaling/max_all_k8s_services.py +41 -0
- paasta_tools/autoscaling/pause_service_autoscaler.py +77 -0
- paasta_tools/autoscaling/utils.py +52 -0
- paasta_tools/bounce_lib.py +184 -0
- paasta_tools/broadcast_log_to_services.py +62 -0
- paasta_tools/cassandracluster_tools.py +210 -0
- paasta_tools/check_autoscaler_max_instances.py +212 -0
- paasta_tools/check_cassandracluster_services_replication.py +35 -0
- paasta_tools/check_flink_services_health.py +203 -0
- paasta_tools/check_kubernetes_api.py +57 -0
- paasta_tools/check_kubernetes_services_replication.py +141 -0
- paasta_tools/check_oom_events.py +244 -0
- paasta_tools/check_services_replication_tools.py +324 -0
- paasta_tools/check_spark_jobs.py +234 -0
- paasta_tools/cleanup_kubernetes_cr.py +138 -0
- paasta_tools/cleanup_kubernetes_crd.py +145 -0
- paasta_tools/cleanup_kubernetes_jobs.py +344 -0
- paasta_tools/cleanup_tron_namespaces.py +96 -0
- paasta_tools/cli/__init__.py +13 -0
- paasta_tools/cli/authentication.py +85 -0
- paasta_tools/cli/cli.py +260 -0
- paasta_tools/cli/cmds/__init__.py +13 -0
- paasta_tools/cli/cmds/autoscale.py +143 -0
- paasta_tools/cli/cmds/check.py +334 -0
- paasta_tools/cli/cmds/cook_image.py +147 -0
- paasta_tools/cli/cmds/get_docker_image.py +76 -0
- paasta_tools/cli/cmds/get_image_version.py +172 -0
- paasta_tools/cli/cmds/get_latest_deployment.py +93 -0
- paasta_tools/cli/cmds/info.py +155 -0
- paasta_tools/cli/cmds/itest.py +117 -0
- paasta_tools/cli/cmds/list.py +66 -0
- paasta_tools/cli/cmds/list_clusters.py +42 -0
- paasta_tools/cli/cmds/list_deploy_queue.py +171 -0
- paasta_tools/cli/cmds/list_namespaces.py +84 -0
- paasta_tools/cli/cmds/local_run.py +1396 -0
- paasta_tools/cli/cmds/logs.py +1601 -0
- paasta_tools/cli/cmds/mark_for_deployment.py +1988 -0
- paasta_tools/cli/cmds/mesh_status.py +174 -0
- paasta_tools/cli/cmds/pause_service_autoscaler.py +107 -0
- paasta_tools/cli/cmds/push_to_registry.py +275 -0
- paasta_tools/cli/cmds/remote_run.py +252 -0
- paasta_tools/cli/cmds/rollback.py +347 -0
- paasta_tools/cli/cmds/secret.py +549 -0
- paasta_tools/cli/cmds/security_check.py +59 -0
- paasta_tools/cli/cmds/spark_run.py +1400 -0
- paasta_tools/cli/cmds/start_stop_restart.py +401 -0
- paasta_tools/cli/cmds/status.py +2302 -0
- paasta_tools/cli/cmds/validate.py +1012 -0
- paasta_tools/cli/cmds/wait_for_deployment.py +275 -0
- paasta_tools/cli/fsm/__init__.py +13 -0
- paasta_tools/cli/fsm/autosuggest.py +82 -0
- paasta_tools/cli/fsm/template/README.md +8 -0
- paasta_tools/cli/fsm/template/cookiecutter.json +7 -0
- paasta_tools/cli/fsm/template/{{cookiecutter.service}}/kubernetes-PROD.yaml +91 -0
- paasta_tools/cli/fsm/template/{{cookiecutter.service}}/monitoring.yaml +20 -0
- paasta_tools/cli/fsm/template/{{cookiecutter.service}}/service.yaml +8 -0
- paasta_tools/cli/fsm/template/{{cookiecutter.service}}/smartstack.yaml +6 -0
- paasta_tools/cli/fsm_cmd.py +121 -0
- paasta_tools/cli/paasta_tabcomplete.sh +23 -0
- paasta_tools/cli/schemas/adhoc_schema.json +199 -0
- paasta_tools/cli/schemas/autoscaling_schema.json +91 -0
- paasta_tools/cli/schemas/autotuned_defaults/cassandracluster_schema.json +37 -0
- paasta_tools/cli/schemas/autotuned_defaults/kubernetes_schema.json +89 -0
- paasta_tools/cli/schemas/deploy_schema.json +173 -0
- paasta_tools/cli/schemas/eks_schema.json +970 -0
- paasta_tools/cli/schemas/kubernetes_schema.json +970 -0
- paasta_tools/cli/schemas/rollback_schema.json +160 -0
- paasta_tools/cli/schemas/service_schema.json +25 -0
- paasta_tools/cli/schemas/smartstack_schema.json +322 -0
- paasta_tools/cli/schemas/tron_schema.json +699 -0
- paasta_tools/cli/utils.py +1118 -0
- paasta_tools/clusterman.py +21 -0
- paasta_tools/config_utils.py +385 -0
- paasta_tools/contrib/__init__.py +0 -0
- paasta_tools/contrib/bounce_log_latency_parser.py +68 -0
- paasta_tools/contrib/check_manual_oapi_changes.sh +24 -0
- paasta_tools/contrib/check_orphans.py +306 -0
- paasta_tools/contrib/create_dynamodb_table.py +35 -0
- paasta_tools/contrib/create_paasta_playground.py +105 -0
- paasta_tools/contrib/emit_allocated_cpu_metrics.py +50 -0
- paasta_tools/contrib/get_running_task_allocation.py +346 -0
- paasta_tools/contrib/habitat_fixer.py +86 -0
- paasta_tools/contrib/ide_helper.py +316 -0
- paasta_tools/contrib/is_pod_healthy_in_proxy.py +139 -0
- paasta_tools/contrib/is_pod_healthy_in_smartstack.py +50 -0
- paasta_tools/contrib/kill_bad_containers.py +109 -0
- paasta_tools/contrib/mass-deploy-tag.sh +44 -0
- paasta_tools/contrib/mock_patch_checker.py +86 -0
- paasta_tools/contrib/paasta_update_soa_memcpu.py +520 -0
- paasta_tools/contrib/render_template.py +129 -0
- paasta_tools/contrib/rightsizer_soaconfigs_update.py +348 -0
- paasta_tools/contrib/service_shard_remove.py +157 -0
- paasta_tools/contrib/service_shard_update.py +373 -0
- paasta_tools/contrib/shared_ip_check.py +77 -0
- paasta_tools/contrib/timeouts_metrics_prom.py +64 -0
- paasta_tools/delete_kubernetes_deployments.py +89 -0
- paasta_tools/deployment_utils.py +44 -0
- paasta_tools/docker_wrapper.py +234 -0
- paasta_tools/docker_wrapper_imports.py +13 -0
- paasta_tools/drain_lib.py +351 -0
- paasta_tools/dump_locally_running_services.py +71 -0
- paasta_tools/eks_tools.py +119 -0
- paasta_tools/envoy_tools.py +373 -0
- paasta_tools/firewall.py +504 -0
- paasta_tools/firewall_logging.py +154 -0
- paasta_tools/firewall_update.py +172 -0
- paasta_tools/flink_tools.py +345 -0
- paasta_tools/flinkeks_tools.py +90 -0
- paasta_tools/frameworks/__init__.py +0 -0
- paasta_tools/frameworks/adhoc_scheduler.py +71 -0
- paasta_tools/frameworks/constraints.py +87 -0
- paasta_tools/frameworks/native_scheduler.py +652 -0
- paasta_tools/frameworks/native_service_config.py +301 -0
- paasta_tools/frameworks/task_store.py +245 -0
- paasta_tools/generate_all_deployments +9 -0
- paasta_tools/generate_authenticating_services.py +94 -0
- paasta_tools/generate_deployments_for_service.py +255 -0
- paasta_tools/generate_services_file.py +114 -0
- paasta_tools/generate_services_yaml.py +30 -0
- paasta_tools/hacheck.py +76 -0
- paasta_tools/instance/__init__.py +0 -0
- paasta_tools/instance/hpa_metrics_parser.py +122 -0
- paasta_tools/instance/kubernetes.py +1362 -0
- paasta_tools/iptables.py +240 -0
- paasta_tools/kafkacluster_tools.py +143 -0
- paasta_tools/kubernetes/__init__.py +0 -0
- paasta_tools/kubernetes/application/__init__.py +0 -0
- paasta_tools/kubernetes/application/controller_wrappers.py +476 -0
- paasta_tools/kubernetes/application/tools.py +90 -0
- paasta_tools/kubernetes/bin/__init__.py +0 -0
- paasta_tools/kubernetes/bin/kubernetes_remove_evicted_pods.py +164 -0
- paasta_tools/kubernetes/bin/paasta_cleanup_remote_run_resources.py +135 -0
- paasta_tools/kubernetes/bin/paasta_cleanup_stale_nodes.py +181 -0
- paasta_tools/kubernetes/bin/paasta_secrets_sync.py +758 -0
- paasta_tools/kubernetes/remote_run.py +558 -0
- paasta_tools/kubernetes_tools.py +4679 -0
- paasta_tools/list_kubernetes_service_instances.py +128 -0
- paasta_tools/list_tron_namespaces.py +60 -0
- paasta_tools/long_running_service_tools.py +678 -0
- paasta_tools/mac_address.py +44 -0
- paasta_tools/marathon_dashboard.py +0 -0
- paasta_tools/mesos/__init__.py +0 -0
- paasta_tools/mesos/cfg.py +46 -0
- paasta_tools/mesos/cluster.py +60 -0
- paasta_tools/mesos/exceptions.py +59 -0
- paasta_tools/mesos/framework.py +77 -0
- paasta_tools/mesos/log.py +48 -0
- paasta_tools/mesos/master.py +306 -0
- paasta_tools/mesos/mesos_file.py +169 -0
- paasta_tools/mesos/parallel.py +52 -0
- paasta_tools/mesos/slave.py +115 -0
- paasta_tools/mesos/task.py +94 -0
- paasta_tools/mesos/util.py +69 -0
- paasta_tools/mesos/zookeeper.py +37 -0
- paasta_tools/mesos_maintenance.py +848 -0
- paasta_tools/mesos_tools.py +1051 -0
- paasta_tools/metrics/__init__.py +0 -0
- paasta_tools/metrics/metastatus_lib.py +1110 -0
- paasta_tools/metrics/metrics_lib.py +217 -0
- paasta_tools/monitoring/__init__.py +13 -0
- paasta_tools/monitoring/check_k8s_api_performance.py +110 -0
- paasta_tools/monitoring_tools.py +652 -0
- paasta_tools/monkrelaycluster_tools.py +146 -0
- paasta_tools/nrtsearchservice_tools.py +143 -0
- paasta_tools/nrtsearchserviceeks_tools.py +68 -0
- paasta_tools/oom_logger.py +321 -0
- paasta_tools/paasta_deploy_tron_jobs +3 -0
- paasta_tools/paasta_execute_docker_command.py +123 -0
- paasta_tools/paasta_native_serviceinit.py +21 -0
- paasta_tools/paasta_service_config_loader.py +201 -0
- paasta_tools/paastaapi/__init__.py +29 -0
- paasta_tools/paastaapi/api/__init__.py +3 -0
- paasta_tools/paastaapi/api/autoscaler_api.py +302 -0
- paasta_tools/paastaapi/api/default_api.py +569 -0
- paasta_tools/paastaapi/api/remote_run_api.py +604 -0
- paasta_tools/paastaapi/api/resources_api.py +157 -0
- paasta_tools/paastaapi/api/service_api.py +1736 -0
- paasta_tools/paastaapi/api_client.py +818 -0
- paasta_tools/paastaapi/apis/__init__.py +22 -0
- paasta_tools/paastaapi/configuration.py +455 -0
- paasta_tools/paastaapi/exceptions.py +137 -0
- paasta_tools/paastaapi/model/__init__.py +5 -0
- paasta_tools/paastaapi/model/adhoc_launch_history.py +176 -0
- paasta_tools/paastaapi/model/autoscaler_count_msg.py +176 -0
- paasta_tools/paastaapi/model/deploy_queue.py +178 -0
- paasta_tools/paastaapi/model/deploy_queue_service_instance.py +194 -0
- paasta_tools/paastaapi/model/envoy_backend.py +185 -0
- paasta_tools/paastaapi/model/envoy_location.py +184 -0
- paasta_tools/paastaapi/model/envoy_status.py +181 -0
- paasta_tools/paastaapi/model/flink_cluster_overview.py +188 -0
- paasta_tools/paastaapi/model/flink_config.py +173 -0
- paasta_tools/paastaapi/model/flink_job.py +186 -0
- paasta_tools/paastaapi/model/flink_job_details.py +192 -0
- paasta_tools/paastaapi/model/flink_jobs.py +175 -0
- paasta_tools/paastaapi/model/float_and_error.py +173 -0
- paasta_tools/paastaapi/model/hpa_metric.py +176 -0
- paasta_tools/paastaapi/model/inline_object.py +170 -0
- paasta_tools/paastaapi/model/inline_response200.py +170 -0
- paasta_tools/paastaapi/model/inline_response2001.py +170 -0
- paasta_tools/paastaapi/model/instance_bounce_status.py +200 -0
- paasta_tools/paastaapi/model/instance_mesh_status.py +186 -0
- paasta_tools/paastaapi/model/instance_status.py +220 -0
- paasta_tools/paastaapi/model/instance_status_adhoc.py +187 -0
- paasta_tools/paastaapi/model/instance_status_cassandracluster.py +173 -0
- paasta_tools/paastaapi/model/instance_status_flink.py +173 -0
- paasta_tools/paastaapi/model/instance_status_kafkacluster.py +173 -0
- paasta_tools/paastaapi/model/instance_status_kubernetes.py +263 -0
- paasta_tools/paastaapi/model/instance_status_kubernetes_autoscaling_status.py +187 -0
- paasta_tools/paastaapi/model/instance_status_kubernetes_v2.py +197 -0
- paasta_tools/paastaapi/model/instance_status_tron.py +204 -0
- paasta_tools/paastaapi/model/instance_tasks.py +182 -0
- paasta_tools/paastaapi/model/integer_and_error.py +173 -0
- paasta_tools/paastaapi/model/kubernetes_container.py +178 -0
- paasta_tools/paastaapi/model/kubernetes_container_v2.py +219 -0
- paasta_tools/paastaapi/model/kubernetes_healthcheck.py +176 -0
- paasta_tools/paastaapi/model/kubernetes_pod.py +201 -0
- paasta_tools/paastaapi/model/kubernetes_pod_event.py +176 -0
- paasta_tools/paastaapi/model/kubernetes_pod_v2.py +213 -0
- paasta_tools/paastaapi/model/kubernetes_replica_set.py +185 -0
- paasta_tools/paastaapi/model/kubernetes_version.py +202 -0
- paasta_tools/paastaapi/model/remote_run_outcome.py +189 -0
- paasta_tools/paastaapi/model/remote_run_start.py +185 -0
- paasta_tools/paastaapi/model/remote_run_stop.py +176 -0
- paasta_tools/paastaapi/model/remote_run_token.py +173 -0
- paasta_tools/paastaapi/model/resource.py +187 -0
- paasta_tools/paastaapi/model/resource_item.py +187 -0
- paasta_tools/paastaapi/model/resource_value.py +176 -0
- paasta_tools/paastaapi/model/smartstack_backend.py +191 -0
- paasta_tools/paastaapi/model/smartstack_location.py +181 -0
- paasta_tools/paastaapi/model/smartstack_status.py +181 -0
- paasta_tools/paastaapi/model/task_tail_lines.py +176 -0
- paasta_tools/paastaapi/model_utils.py +1879 -0
- paasta_tools/paastaapi/models/__init__.py +62 -0
- paasta_tools/paastaapi/rest.py +287 -0
- paasta_tools/prune_completed_pods.py +220 -0
- paasta_tools/puppet_service_tools.py +59 -0
- paasta_tools/py.typed +1 -0
- paasta_tools/remote_git.py +127 -0
- paasta_tools/run-paasta-api-in-dev-mode.py +57 -0
- paasta_tools/run-paasta-api-playground.py +51 -0
- paasta_tools/secret_providers/__init__.py +66 -0
- paasta_tools/secret_providers/vault.py +214 -0
- paasta_tools/secret_tools.py +277 -0
- paasta_tools/setup_istio_mesh.py +353 -0
- paasta_tools/setup_kubernetes_cr.py +412 -0
- paasta_tools/setup_kubernetes_crd.py +138 -0
- paasta_tools/setup_kubernetes_internal_crd.py +154 -0
- paasta_tools/setup_kubernetes_job.py +353 -0
- paasta_tools/setup_prometheus_adapter_config.py +1028 -0
- paasta_tools/setup_tron_namespace.py +248 -0
- paasta_tools/slack.py +75 -0
- paasta_tools/smartstack_tools.py +676 -0
- paasta_tools/spark_tools.py +283 -0
- paasta_tools/synapse_srv_namespaces_fact.py +42 -0
- paasta_tools/tron/__init__.py +0 -0
- paasta_tools/tron/client.py +158 -0
- paasta_tools/tron/tron_command_context.py +194 -0
- paasta_tools/tron/tron_timeutils.py +101 -0
- paasta_tools/tron_tools.py +1448 -0
- paasta_tools/utils.py +4307 -0
- paasta_tools/yaml_tools.py +44 -0
- paasta_tools-1.21.3.data/scripts/apply_external_resources.py +79 -0
- paasta_tools-1.21.3.data/scripts/bounce_log_latency_parser.py +68 -0
- paasta_tools-1.21.3.data/scripts/check_autoscaler_max_instances.py +212 -0
- paasta_tools-1.21.3.data/scripts/check_cassandracluster_services_replication.py +35 -0
- paasta_tools-1.21.3.data/scripts/check_flink_services_health.py +203 -0
- paasta_tools-1.21.3.data/scripts/check_kubernetes_api.py +57 -0
- paasta_tools-1.21.3.data/scripts/check_kubernetes_services_replication.py +141 -0
- paasta_tools-1.21.3.data/scripts/check_manual_oapi_changes.sh +24 -0
- paasta_tools-1.21.3.data/scripts/check_oom_events.py +244 -0
- paasta_tools-1.21.3.data/scripts/check_orphans.py +306 -0
- paasta_tools-1.21.3.data/scripts/check_spark_jobs.py +234 -0
- paasta_tools-1.21.3.data/scripts/cleanup_kubernetes_cr.py +138 -0
- paasta_tools-1.21.3.data/scripts/cleanup_kubernetes_crd.py +145 -0
- paasta_tools-1.21.3.data/scripts/cleanup_kubernetes_jobs.py +344 -0
- paasta_tools-1.21.3.data/scripts/create_dynamodb_table.py +35 -0
- paasta_tools-1.21.3.data/scripts/create_paasta_playground.py +105 -0
- paasta_tools-1.21.3.data/scripts/delete_kubernetes_deployments.py +89 -0
- paasta_tools-1.21.3.data/scripts/emit_allocated_cpu_metrics.py +50 -0
- paasta_tools-1.21.3.data/scripts/generate_all_deployments +9 -0
- paasta_tools-1.21.3.data/scripts/generate_authenticating_services.py +94 -0
- paasta_tools-1.21.3.data/scripts/generate_deployments_for_service.py +255 -0
- paasta_tools-1.21.3.data/scripts/generate_services_file.py +114 -0
- paasta_tools-1.21.3.data/scripts/generate_services_yaml.py +30 -0
- paasta_tools-1.21.3.data/scripts/get_running_task_allocation.py +346 -0
- paasta_tools-1.21.3.data/scripts/habitat_fixer.py +86 -0
- paasta_tools-1.21.3.data/scripts/ide_helper.py +316 -0
- paasta_tools-1.21.3.data/scripts/is_pod_healthy_in_proxy.py +139 -0
- paasta_tools-1.21.3.data/scripts/is_pod_healthy_in_smartstack.py +50 -0
- paasta_tools-1.21.3.data/scripts/kill_bad_containers.py +109 -0
- paasta_tools-1.21.3.data/scripts/kubernetes_remove_evicted_pods.py +164 -0
- paasta_tools-1.21.3.data/scripts/mass-deploy-tag.sh +44 -0
- paasta_tools-1.21.3.data/scripts/mock_patch_checker.py +86 -0
- paasta_tools-1.21.3.data/scripts/paasta_cleanup_remote_run_resources.py +135 -0
- paasta_tools-1.21.3.data/scripts/paasta_cleanup_stale_nodes.py +181 -0
- paasta_tools-1.21.3.data/scripts/paasta_deploy_tron_jobs +3 -0
- paasta_tools-1.21.3.data/scripts/paasta_execute_docker_command.py +123 -0
- paasta_tools-1.21.3.data/scripts/paasta_secrets_sync.py +758 -0
- paasta_tools-1.21.3.data/scripts/paasta_tabcomplete.sh +23 -0
- paasta_tools-1.21.3.data/scripts/paasta_update_soa_memcpu.py +520 -0
- paasta_tools-1.21.3.data/scripts/render_template.py +129 -0
- paasta_tools-1.21.3.data/scripts/rightsizer_soaconfigs_update.py +348 -0
- paasta_tools-1.21.3.data/scripts/service_shard_remove.py +157 -0
- paasta_tools-1.21.3.data/scripts/service_shard_update.py +373 -0
- paasta_tools-1.21.3.data/scripts/setup_istio_mesh.py +353 -0
- paasta_tools-1.21.3.data/scripts/setup_kubernetes_cr.py +412 -0
- paasta_tools-1.21.3.data/scripts/setup_kubernetes_crd.py +138 -0
- paasta_tools-1.21.3.data/scripts/setup_kubernetes_internal_crd.py +154 -0
- paasta_tools-1.21.3.data/scripts/setup_kubernetes_job.py +353 -0
- paasta_tools-1.21.3.data/scripts/setup_prometheus_adapter_config.py +1028 -0
- paasta_tools-1.21.3.data/scripts/shared_ip_check.py +77 -0
- paasta_tools-1.21.3.data/scripts/synapse_srv_namespaces_fact.py +42 -0
- paasta_tools-1.21.3.data/scripts/timeouts_metrics_prom.py +64 -0
- paasta_tools-1.21.3.dist-info/LICENSE +201 -0
- paasta_tools-1.21.3.dist-info/METADATA +74 -0
- paasta_tools-1.21.3.dist-info/RECORD +348 -0
- paasta_tools-1.21.3.dist-info/WHEEL +5 -0
- paasta_tools-1.21.3.dist-info/entry_points.txt +20 -0
- paasta_tools-1.21.3.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# Copyright 2015-2016 Yelp Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
"""Contains methods used by the paasta client to wait for deployment
|
|
16
|
+
of a docker image to a cluster.instance.
|
|
17
|
+
"""
|
|
18
|
+
import asyncio
|
|
19
|
+
import logging
|
|
20
|
+
from typing import Optional
|
|
21
|
+
|
|
22
|
+
from paasta_tools.cli.cmds.mark_for_deployment import NoSuchCluster
|
|
23
|
+
from paasta_tools.cli.cmds.mark_for_deployment import report_waiting_aborted
|
|
24
|
+
from paasta_tools.cli.cmds.mark_for_deployment import wait_for_deployment
|
|
25
|
+
from paasta_tools.cli.utils import lazy_choices_completer
|
|
26
|
+
from paasta_tools.cli.utils import list_deploy_groups
|
|
27
|
+
from paasta_tools.cli.utils import NoSuchService
|
|
28
|
+
from paasta_tools.cli.utils import validate_git_sha
|
|
29
|
+
from paasta_tools.cli.utils import validate_given_deploy_groups
|
|
30
|
+
from paasta_tools.cli.utils import validate_service_name
|
|
31
|
+
from paasta_tools.cli.utils import validate_short_git_sha
|
|
32
|
+
from paasta_tools.remote_git import list_remote_refs
|
|
33
|
+
from paasta_tools.remote_git import LSRemoteException
|
|
34
|
+
from paasta_tools.utils import _log
|
|
35
|
+
from paasta_tools.utils import DEFAULT_SOA_DIR
|
|
36
|
+
from paasta_tools.utils import DeploymentVersion
|
|
37
|
+
from paasta_tools.utils import get_git_url
|
|
38
|
+
from paasta_tools.utils import get_latest_deployment_tag
|
|
39
|
+
from paasta_tools.utils import list_services
|
|
40
|
+
from paasta_tools.utils import PaastaColors
|
|
41
|
+
from paasta_tools.utils import TimeoutError
|
|
42
|
+
|
|
43
|
+
DEFAULT_DEPLOYMENT_TIMEOUT = 3600 # seconds
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
log = logging.getLogger(__name__)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class VersionError(Exception):
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class DeployGroupError(Exception):
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def add_subparser(subparsers):
|
|
58
|
+
list_parser = subparsers.add_parser(
|
|
59
|
+
"wait-for-deployment",
|
|
60
|
+
help="Wait a service to be deployed to deploy_group",
|
|
61
|
+
description=(
|
|
62
|
+
"'paasta wait-for-deployment' waits for a previously marked for "
|
|
63
|
+
"deployment service to be deployed to deploy_group."
|
|
64
|
+
),
|
|
65
|
+
epilog=(
|
|
66
|
+
"Note: Access and credentials to the Git repo of a service "
|
|
67
|
+
"are required for this command to work."
|
|
68
|
+
),
|
|
69
|
+
)
|
|
70
|
+
list_parser.add_argument(
|
|
71
|
+
"-u",
|
|
72
|
+
"--git-url",
|
|
73
|
+
help=(
|
|
74
|
+
"Git url for service. Defaults to the normal git URL for " "the service."
|
|
75
|
+
),
|
|
76
|
+
default=None,
|
|
77
|
+
)
|
|
78
|
+
list_parser.add_argument(
|
|
79
|
+
"-c",
|
|
80
|
+
"-k",
|
|
81
|
+
"--commit",
|
|
82
|
+
help="Git sha to wait for deployment",
|
|
83
|
+
required=True,
|
|
84
|
+
type=validate_short_git_sha,
|
|
85
|
+
)
|
|
86
|
+
list_parser.add_argument(
|
|
87
|
+
"-i",
|
|
88
|
+
"--image-version",
|
|
89
|
+
help="Extra version metadata to mark for deployment",
|
|
90
|
+
required=False,
|
|
91
|
+
default=None,
|
|
92
|
+
)
|
|
93
|
+
list_parser.add_argument(
|
|
94
|
+
"-l",
|
|
95
|
+
"--deploy-group",
|
|
96
|
+
help="deploy group (e.g. cluster1.canary, cluster2.main).",
|
|
97
|
+
required=True,
|
|
98
|
+
).completer = lazy_choices_completer(list_deploy_groups)
|
|
99
|
+
list_parser.add_argument(
|
|
100
|
+
"-s",
|
|
101
|
+
"--service",
|
|
102
|
+
help="Name of the service which you wish to wait for deployment. "
|
|
103
|
+
'Leading "services-" will be stripped.',
|
|
104
|
+
required=True,
|
|
105
|
+
).completer = lazy_choices_completer(list_services)
|
|
106
|
+
list_parser.add_argument(
|
|
107
|
+
"-t",
|
|
108
|
+
"--timeout",
|
|
109
|
+
dest="timeout",
|
|
110
|
+
type=int,
|
|
111
|
+
default=DEFAULT_DEPLOYMENT_TIMEOUT,
|
|
112
|
+
help=(
|
|
113
|
+
"Time in seconds to wait for paasta to deploy the service. "
|
|
114
|
+
"If the timeout is exceeded we return 1. "
|
|
115
|
+
"Default is %(default)s seconds."
|
|
116
|
+
),
|
|
117
|
+
)
|
|
118
|
+
list_parser.add_argument(
|
|
119
|
+
"-d",
|
|
120
|
+
"--soa-dir",
|
|
121
|
+
dest="soa_dir",
|
|
122
|
+
metavar="SOA_DIR",
|
|
123
|
+
default=DEFAULT_SOA_DIR,
|
|
124
|
+
help="define a different soa config directory",
|
|
125
|
+
)
|
|
126
|
+
list_parser.add_argument(
|
|
127
|
+
"-v",
|
|
128
|
+
"--verbose",
|
|
129
|
+
action="count",
|
|
130
|
+
dest="verbose",
|
|
131
|
+
default=0,
|
|
132
|
+
help="Print out more output.",
|
|
133
|
+
)
|
|
134
|
+
list_parser.add_argument(
|
|
135
|
+
"--polling-interval",
|
|
136
|
+
dest="polling_interval",
|
|
137
|
+
type=float,
|
|
138
|
+
default=None,
|
|
139
|
+
help="How long to wait between each time we check to see if an instance is done deploying.",
|
|
140
|
+
)
|
|
141
|
+
list_parser.add_argument(
|
|
142
|
+
"--diagnosis-interval",
|
|
143
|
+
dest="diagnosis_interval",
|
|
144
|
+
type=float,
|
|
145
|
+
default=None,
|
|
146
|
+
help="How long to wait between diagnoses of why the bounce isn't done.",
|
|
147
|
+
)
|
|
148
|
+
list_parser.add_argument(
|
|
149
|
+
"--time-before-first-diagnosis",
|
|
150
|
+
dest="time_before_first_diagnosis",
|
|
151
|
+
type=float,
|
|
152
|
+
default=None,
|
|
153
|
+
help="Wait this long before trying to diagnose why the bounce isn't done.",
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
list_parser.set_defaults(command=paasta_wait_for_deployment)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def get_latest_marked_version(
|
|
160
|
+
git_url: str, deploy_group: str
|
|
161
|
+
) -> Optional[DeploymentVersion]:
|
|
162
|
+
"""Return the latest marked for deployment version or None"""
|
|
163
|
+
# TODO: correct this function for new tag format
|
|
164
|
+
refs = list_remote_refs(git_url)
|
|
165
|
+
_, sha, image_version = get_latest_deployment_tag(refs, deploy_group)
|
|
166
|
+
if sha:
|
|
167
|
+
return DeploymentVersion(sha=sha, image_version=image_version)
|
|
168
|
+
# We did not find a ref for this deploy group
|
|
169
|
+
return None
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def validate_version_is_latest(
|
|
173
|
+
version: DeploymentVersion, git_url: str, deploy_group: str, service: str
|
|
174
|
+
):
|
|
175
|
+
"""Verify if the requested version is the latest marked for deployment.
|
|
176
|
+
|
|
177
|
+
Raise exception when the provided version is not the latest
|
|
178
|
+
marked for deployment in 'deploy_group' for 'service'.
|
|
179
|
+
"""
|
|
180
|
+
try:
|
|
181
|
+
marked_version = get_latest_marked_version(git_url, deploy_group)
|
|
182
|
+
except LSRemoteException as e:
|
|
183
|
+
print(
|
|
184
|
+
"Error talking to the git server: {}\n"
|
|
185
|
+
"It is not possible to verify that {} is marked for deployment in {}, "
|
|
186
|
+
"but I assume that it is marked and will continue waiting..".format(
|
|
187
|
+
e, version, deploy_group
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
return
|
|
191
|
+
if marked_version is None:
|
|
192
|
+
raise VersionError(
|
|
193
|
+
"ERROR: Nothing is marked for deployment "
|
|
194
|
+
"in {} for {}".format(deploy_group, service)
|
|
195
|
+
)
|
|
196
|
+
if version != marked_version:
|
|
197
|
+
raise VersionError(
|
|
198
|
+
"ERROR: The latest version marked for "
|
|
199
|
+
"deployment in {} is {}".format(deploy_group, marked_version)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def validate_deploy_group(deploy_group: str, service: str, soa_dir: str):
|
|
204
|
+
"""Validate deploy_group.
|
|
205
|
+
|
|
206
|
+
Raise exception if the specified deploy group is not used anywhere.
|
|
207
|
+
"""
|
|
208
|
+
in_use_deploy_groups = list_deploy_groups(service=service, soa_dir=soa_dir)
|
|
209
|
+
_, invalid_deploy_groups = validate_given_deploy_groups(
|
|
210
|
+
in_use_deploy_groups, [deploy_group]
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
if len(invalid_deploy_groups) == 1:
|
|
214
|
+
raise DeployGroupError(
|
|
215
|
+
"ERROR: These deploy groups are not currently "
|
|
216
|
+
"used anywhere: {}.\n"
|
|
217
|
+
"You probably need one of these in-use deploy "
|
|
218
|
+
"groups?:\n {}".format(
|
|
219
|
+
",".join(invalid_deploy_groups), ",".join(in_use_deploy_groups)
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def paasta_wait_for_deployment(args):
|
|
225
|
+
"""Wrapping wait_for_deployment"""
|
|
226
|
+
if args.verbose:
|
|
227
|
+
log.setLevel(level=logging.DEBUG)
|
|
228
|
+
else:
|
|
229
|
+
log.setLevel(level=logging.INFO)
|
|
230
|
+
|
|
231
|
+
service = args.service
|
|
232
|
+
if service and service.startswith("services-"):
|
|
233
|
+
service = service.split("services-", 1)[1]
|
|
234
|
+
|
|
235
|
+
if args.git_url is None:
|
|
236
|
+
args.git_url = get_git_url(service=service, soa_dir=args.soa_dir)
|
|
237
|
+
|
|
238
|
+
args.commit = validate_git_sha(sha=args.commit, git_url=args.git_url)
|
|
239
|
+
|
|
240
|
+
version = DeploymentVersion(sha=args.commit, image_version=args.image_version)
|
|
241
|
+
|
|
242
|
+
try:
|
|
243
|
+
validate_service_name(service, soa_dir=args.soa_dir)
|
|
244
|
+
validate_deploy_group(args.deploy_group, service, args.soa_dir)
|
|
245
|
+
validate_version_is_latest(version, args.git_url, args.deploy_group, service)
|
|
246
|
+
except (VersionError, DeployGroupError, NoSuchService) as e:
|
|
247
|
+
print(PaastaColors.red(f"{e}"))
|
|
248
|
+
return 1
|
|
249
|
+
|
|
250
|
+
try:
|
|
251
|
+
asyncio.run(
|
|
252
|
+
wait_for_deployment(
|
|
253
|
+
service=service,
|
|
254
|
+
deploy_group=args.deploy_group,
|
|
255
|
+
git_sha=args.commit,
|
|
256
|
+
image_version=args.image_version,
|
|
257
|
+
soa_dir=args.soa_dir,
|
|
258
|
+
timeout=args.timeout,
|
|
259
|
+
polling_interval=args.polling_interval,
|
|
260
|
+
diagnosis_interval=args.diagnosis_interval,
|
|
261
|
+
time_before_first_diagnosis=args.time_before_first_diagnosis,
|
|
262
|
+
)
|
|
263
|
+
)
|
|
264
|
+
_log(
|
|
265
|
+
service=service,
|
|
266
|
+
component="deploy",
|
|
267
|
+
line=(f"Deployment of {version} for {args.deploy_group} complete"),
|
|
268
|
+
level="event",
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
except (KeyboardInterrupt, TimeoutError, NoSuchCluster):
|
|
272
|
+
report_waiting_aborted(service, args.deploy_group)
|
|
273
|
+
return 1
|
|
274
|
+
|
|
275
|
+
return 0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2015-2016 Yelp Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Copyright 2015-2016 Yelp Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
import os
|
|
15
|
+
import random
|
|
16
|
+
|
|
17
|
+
from paasta_tools import yaml_tools as yaml
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _get_smartstack_proxy_ports_from_file(root, file):
|
|
21
|
+
"""Given a root and file (as from os.walk), attempt to return the highest
|
|
22
|
+
smartstack proxy port number (int) from that file. Returns 0 if there is no
|
|
23
|
+
smartstack proxy_port.
|
|
24
|
+
"""
|
|
25
|
+
ports = set()
|
|
26
|
+
with open(os.path.join(root, file)) as f:
|
|
27
|
+
data = yaml.safe_load(f)
|
|
28
|
+
|
|
29
|
+
if file.endswith("service.yaml") and "smartstack" in data:
|
|
30
|
+
# Specifying this in service.yaml is old and deprecated and doesn't
|
|
31
|
+
# support multiple namespaces.
|
|
32
|
+
ports = {int(data["smartstack"].get("proxy_port", 0))}
|
|
33
|
+
elif file.endswith("smartstack.yaml"):
|
|
34
|
+
for namespace in data.keys():
|
|
35
|
+
ports.add(data[namespace].get("proxy_port", 0))
|
|
36
|
+
|
|
37
|
+
return ports
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def read_etc_services():
|
|
41
|
+
with open("/etc/services") as fd:
|
|
42
|
+
return fd.readlines()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_inuse_ports_from_etc_services():
|
|
46
|
+
ports = set()
|
|
47
|
+
for line in read_etc_services():
|
|
48
|
+
if line.startswith("#"):
|
|
49
|
+
continue
|
|
50
|
+
try:
|
|
51
|
+
p = line.split()[1]
|
|
52
|
+
port = int(p.split("/")[0])
|
|
53
|
+
ports.add(port)
|
|
54
|
+
except Exception:
|
|
55
|
+
pass
|
|
56
|
+
return ports
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def suggest_smartstack_proxy_port(
|
|
60
|
+
yelpsoa_config_root, range_min=19000, range_max=21000
|
|
61
|
+
):
|
|
62
|
+
"""Pick a random available port in the 19000-21000 block"""
|
|
63
|
+
available_proxy_ports = set(range(range_min, range_max + 1))
|
|
64
|
+
for root, dirs, files in os.walk(yelpsoa_config_root):
|
|
65
|
+
for f in files:
|
|
66
|
+
if f.endswith("smartstack.yaml"):
|
|
67
|
+
try:
|
|
68
|
+
used_ports = _get_smartstack_proxy_ports_from_file(root, f)
|
|
69
|
+
for used_port in used_ports:
|
|
70
|
+
available_proxy_ports.discard(used_port)
|
|
71
|
+
except Exception:
|
|
72
|
+
pass
|
|
73
|
+
available_proxy_ports.difference_update(get_inuse_ports_from_etc_services())
|
|
74
|
+
try:
|
|
75
|
+
return random.choice(list(available_proxy_ports))
|
|
76
|
+
except IndexError:
|
|
77
|
+
raise Exception(
|
|
78
|
+
f"There are no more ports available in the range [{range_min}, {range_max}]"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# vim: expandtab tabstop=4 sts=4 shiftwidth=4:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
== PaaSTA FSM Template
|
|
2
|
+
|
|
3
|
+
This is a [cookiecutter](http://cookiecutter.readthedocs.io/en/latest/index.html) style
|
|
4
|
+
template to make it easier for you to create new services in PaaSTA.
|
|
5
|
+
|
|
6
|
+
Use the `paasta fsm` tool to read this template.
|
|
7
|
+
|
|
8
|
+
Only a very basic template is provided here.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Kubernetes is the PaaSTA component that takes a command and keeps copies of it running.
|
|
3
|
+
# You can see all the options for this file here:
|
|
4
|
+
# http://paasta.readthedocs.org/en/latest/yelpsoa_configs.html#kubernetes-clustername-yaml
|
|
5
|
+
|
|
6
|
+
# In PaaSTA you can have different "instances" of the service that can run in different
|
|
7
|
+
# modes. Out of Yelp convention, the "main" instance is the primary one and serves main
|
|
8
|
+
# web traffic.
|
|
9
|
+
main:
|
|
10
|
+
# In Prod, it is important to have enough capacity to serve our users. Having 3 copies
|
|
11
|
+
# of the service is a good start. Longer term the service might need more. Follow up
|
|
12
|
+
# and check out the autoscaling documentation:
|
|
13
|
+
# http://paasta.readthedocs.org/en/latest/autoscaling.html
|
|
14
|
+
# to learn how to have the "right" number of instances all the time.
|
|
15
|
+
instances: 3
|
|
16
|
+
|
|
17
|
+
deploy_group: everything
|
|
18
|
+
|
|
19
|
+
# cpus is a soft limit, and services can burst to use extra cpus on the servers
|
|
20
|
+
# if they are available. `paasta status` can give a snapshot of how much
|
|
21
|
+
# cpu a service is using or the signalfx graphs can give you a view of the cpu
|
|
22
|
+
# over time. Be honest about your cpu needs to keep the scheduler informed
|
|
23
|
+
# and neighbors happy.
|
|
24
|
+
cpus: .1
|
|
25
|
+
#
|
|
26
|
+
# Mem is hard limit and at Yelp we don't allow swap. The service will OOM and die
|
|
27
|
+
# if it goes over the limit. Luckily Kubernetes will restart the service ASAP if that
|
|
28
|
+
# happens. If it happens too much you will lose replication and get an alert. Again
|
|
29
|
+
# use the Signalfx graphs to keep an eye on it and give yourself headroom.
|
|
30
|
+
mem: 1000
|
|
31
|
+
|
|
32
|
+
# All the monitoring options in monitoring.yaml can be set on a per-instance basis too.
|
|
33
|
+
# You can even change the team responsible! Uncomment as necessary.
|
|
34
|
+
#monitoring:
|
|
35
|
+
# page: true
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# A "canary" instance is useful to most people. The difference here is that it is in different
|
|
39
|
+
# deploy_group that is deployed "earlier" in the jenkins pipeline. In real life you could make
|
|
40
|
+
# the canary do whatever you want. It could have a special `cmd`, or run with different amounts
|
|
41
|
+
# of ram/cpu, read a different config file, etc.
|
|
42
|
+
canary:
|
|
43
|
+
instances: 1
|
|
44
|
+
deploy_group: canary
|
|
45
|
+
cpus: .1
|
|
46
|
+
mem: 1000
|
|
47
|
+
# This nerve_ns line configures the instance to "show up" in the "main" pool in SmartStack.
|
|
48
|
+
# This means that live traffic hitting the "main" pool will hit the canary. Most of the time
|
|
49
|
+
# this is what services want, but you should be aware of how this "works".
|
|
50
|
+
#
|
|
51
|
+
# For example, if you had 3 instances for main, and 1 instance for this canary, if you look
|
|
52
|
+
# at a HAProxy dashboard for Smartstack, you would see 4 backends!
|
|
53
|
+
nerve_ns: main
|
|
54
|
+
|
|
55
|
+
# All the monitoring options in monitoring.yaml can be set on a per-instance basis too.
|
|
56
|
+
# You can even change the team responsible! Uncomment as necessary.
|
|
57
|
+
#monitoring:
|
|
58
|
+
# page: false
|
|
59
|
+
# ticket: true
|
|
60
|
+
# slack_channels: ['mychannel']
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# Some service authors want a *different* canary that is not in the main smartstack pool
|
|
64
|
+
# that they can hit directly. You can totally do this, but you have to uncomment such
|
|
65
|
+
# an instance below, and also add the new smartstack.yaml section to correspond with it.
|
|
66
|
+
# non_traffic_receiving_canary:
|
|
67
|
+
# instances: 1
|
|
68
|
+
# deploy_group: prod.canary
|
|
69
|
+
# cpus: .1
|
|
70
|
+
# mem: 2000
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Running "workers" in paasta is easy. There isn't really anything special about them except
|
|
74
|
+
# they probably have a special `cmd`. Of course you could change the deploy group if you wanted
|
|
75
|
+
# a canary worker. You can change instances, autoscale, etc.
|
|
76
|
+
#worker:
|
|
77
|
+
# instances: 1
|
|
78
|
+
# deploy_group: prod.non_canary
|
|
79
|
+
# cpus: .1
|
|
80
|
+
# mem: 1000
|
|
81
|
+
# cmd: /code/virtualenv_run/bin/python /code/my_worker.py
|
|
82
|
+
# # There are also more options for specifying command healthchecks
|
|
83
|
+
# # if you need a special healthcheck command, but by default
|
|
84
|
+
# # Mesos will watch the process (PID) and consider it healthy if
|
|
85
|
+
# # it exists.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# Worried about lots of duplication? You can use the YAML Anchor pattern to help with that:
|
|
89
|
+
# https://en.wikipedia.org/wiki/YAML#Repeated_nodes
|
|
90
|
+
# It is an advanced topic. If you do try it out, be sure to ask #paasta or add the paasta
|
|
91
|
+
# review board group to the review.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
# All of these options are documented here:
|
|
3
|
+
# http://paasta.readthedocs.org/en/latest/yelpsoa_configs.html#monitoring-yaml
|
|
4
|
+
|
|
5
|
+
team: {{cookiecutter.team}}
|
|
6
|
+
page: true
|
|
7
|
+
# If you add a runbook here, it will get included in all the
|
|
8
|
+
# sensu alerts that are generated for this service
|
|
9
|
+
#runbook: http://y/rb-{{cookiecutter.service}}
|
|
10
|
+
|
|
11
|
+
# Alert after is a kind of grace period before alerts are sent.
|
|
12
|
+
# Usually the defaults are fine, but you can up this if you need
|
|
13
|
+
# to.
|
|
14
|
+
#alert_after: 2m
|
|
15
|
+
|
|
16
|
+
# realert_every represents how often to resend an email or irc.
|
|
17
|
+
# By default it does exponential backoff, which can be a little
|
|
18
|
+
# noisy at first but then will quiet down. You can override this
|
|
19
|
+
# if you want it to be consistently "noisy":
|
|
20
|
+
#realert_every: 3600
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
# This shows up in `paasta info` and is helpful
|
|
3
|
+
# for people who have never heard of this service before. What does it do?
|
|
4
|
+
description: {{cookiecutter.description}}
|
|
5
|
+
|
|
6
|
+
# This is designed to help answer the question of
|
|
7
|
+
# "Why did we make this service in the first place?"
|
|
8
|
+
external_link: {{cookiecutter.external_link}}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# Copyright 2015-2016 Yelp Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
import argparse
|
|
16
|
+
import contextlib
|
|
17
|
+
import shutil
|
|
18
|
+
import sys
|
|
19
|
+
|
|
20
|
+
from cookiecutter.main import cookiecutter
|
|
21
|
+
|
|
22
|
+
from paasta_tools.cli.fsm.autosuggest import suggest_smartstack_proxy_port
|
|
23
|
+
from paasta_tools.utils import load_system_paasta_config
|
|
24
|
+
from paasta_tools.utils import PaastaColors
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@contextlib.contextmanager
|
|
28
|
+
def make_copyfile_symlink_aware():
|
|
29
|
+
"""The reasoning behind this monkeypatch is that cookiecutter doesn't
|
|
30
|
+
respect symlinks at all, and at Yelp we use symlinks to reduce duplication
|
|
31
|
+
in the soa configs. Maybe cookie-cutter will accept a symlink-aware PR?
|
|
32
|
+
"""
|
|
33
|
+
orig_copyfile = shutil.copyfile
|
|
34
|
+
orig_copymode = shutil.copymode
|
|
35
|
+
|
|
36
|
+
def symlink_aware_copyfile(*args, **kwargs):
|
|
37
|
+
kwargs.setdefault("follow_symlinks", False)
|
|
38
|
+
orig_copyfile(*args, **kwargs)
|
|
39
|
+
|
|
40
|
+
def symlink_aware_copymode(*args, **kwargs):
|
|
41
|
+
kwargs.setdefault("follow_symlinks", False)
|
|
42
|
+
orig_copymode(*args, **kwargs)
|
|
43
|
+
|
|
44
|
+
shutil.copyfile = symlink_aware_copyfile
|
|
45
|
+
shutil.copymode = symlink_aware_copymode
|
|
46
|
+
try:
|
|
47
|
+
yield
|
|
48
|
+
finally:
|
|
49
|
+
shutil.copyfile = orig_copyfile
|
|
50
|
+
shutil.copymode = orig_copymode
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def parse_args():
|
|
54
|
+
fsm_parser = argparse.ArgumentParser(
|
|
55
|
+
"fsm",
|
|
56
|
+
description=(
|
|
57
|
+
"'paasta fsm' is used to generate example soa-configs, which is useful during initial "
|
|
58
|
+
"service creation. Currently 'fsm' generates 'yelp-specific' configuration, but can still "
|
|
59
|
+
"be used as an example of a fully working PaaSTA service.\n\n"
|
|
60
|
+
"After 'paasta fsm' is run, the operator should inspect the generated boilerplate configuration "
|
|
61
|
+
"and adjust it to meet the particular needs of the new service."
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
fsm_parser.add_argument(
|
|
65
|
+
"-y",
|
|
66
|
+
"--yelpsoa-config-root",
|
|
67
|
+
dest="yelpsoa_config_root",
|
|
68
|
+
default=".",
|
|
69
|
+
help=(
|
|
70
|
+
"Path to root of yelpsoa-configs checkout\n"
|
|
71
|
+
"Defaults to current working directory"
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
fsm_parser.set_defaults(command=paasta_fsm)
|
|
75
|
+
return fsm_parser.parse_args()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def get_paasta_config(yelpsoa_config_root):
|
|
79
|
+
variables = {"proxy_port": suggest_smartstack_proxy_port(yelpsoa_config_root)}
|
|
80
|
+
return variables
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def write_paasta_config(variables, template, destination):
|
|
84
|
+
print("Using cookiecutter template from %s" % template)
|
|
85
|
+
with make_copyfile_symlink_aware():
|
|
86
|
+
cookiecutter(
|
|
87
|
+
template=template,
|
|
88
|
+
extra_context=variables,
|
|
89
|
+
output_dir=destination,
|
|
90
|
+
overwrite_if_exists=True,
|
|
91
|
+
no_input=not sys.stdout.isatty(),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def paasta_fsm(args):
|
|
96
|
+
variables = get_paasta_config(yelpsoa_config_root=args.yelpsoa_config_root)
|
|
97
|
+
destination = args.yelpsoa_config_root
|
|
98
|
+
|
|
99
|
+
paasta_config = load_system_paasta_config()
|
|
100
|
+
template = paasta_config.get_fsm_template()
|
|
101
|
+
|
|
102
|
+
write_paasta_config(variables=variables, template=template, destination=destination)
|
|
103
|
+
|
|
104
|
+
print(PaastaColors.yellow(" _ _(o)_(o)_ _"))
|
|
105
|
+
print(PaastaColors.red(r" ._\`:_ F S M _:' \_,"))
|
|
106
|
+
print(PaastaColors.green(r" / (`---'\ `-."))
|
|
107
|
+
print(PaastaColors.cyan(" ,-` _) (_,"))
|
|
108
|
+
print("With My Noodly Appendage I Have Written Configs!")
|
|
109
|
+
print()
|
|
110
|
+
print("Customize Them If It Makes You Happy -- http://y/paasta For Details")
|
|
111
|
+
print("Remember To Add, Commit, And Push When You're Done:")
|
|
112
|
+
print()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def main():
|
|
116
|
+
args = parse_args()
|
|
117
|
+
paasta_fsm(args)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
main()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Copyright 2015-2016 Yelp Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
if [[ -n ${ZSH_VERSION-} ]]; then
|
|
17
|
+
autoload -U +X bashcompinit && bashcompinit
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# This magic eval enables tab-completion for the "paasta" command
|
|
21
|
+
# http://argcomplete.readthedocs.io/en/latest/index.html#synopsis
|
|
22
|
+
# This comes from the paasta-tools system package
|
|
23
|
+
eval "$(/opt/venvs/paasta-tools/bin/register-python-argcomplete paasta)"
|