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,346 @@
|
|
|
1
|
+
#!python
|
|
2
|
+
import argparse
|
|
3
|
+
import time
|
|
4
|
+
from typing import Any
|
|
5
|
+
from typing import Dict
|
|
6
|
+
from typing import Iterable
|
|
7
|
+
from typing import List
|
|
8
|
+
from typing import Mapping
|
|
9
|
+
from typing import MutableMapping
|
|
10
|
+
from typing import NamedTuple
|
|
11
|
+
from typing import Optional
|
|
12
|
+
from typing import Tuple
|
|
13
|
+
|
|
14
|
+
import a_sync
|
|
15
|
+
import simplejson as json
|
|
16
|
+
from kubernetes.client import V1Pod
|
|
17
|
+
from kubernetes.client import V1ResourceRequirements
|
|
18
|
+
|
|
19
|
+
from paasta_tools import kubernetes_tools
|
|
20
|
+
from paasta_tools import mesos_tools
|
|
21
|
+
from paasta_tools.kubernetes_tools import KubeClient
|
|
22
|
+
from paasta_tools.mesos.exceptions import SlaveDoesNotExist
|
|
23
|
+
from paasta_tools.mesos.task import Task
|
|
24
|
+
from paasta_tools.utils import load_system_paasta_config
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
MAIN_CONTAINER_TYPE = "main"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TaskAllocationInfo(NamedTuple):
|
|
31
|
+
paasta_service: str
|
|
32
|
+
paasta_instance: str
|
|
33
|
+
container_type: str
|
|
34
|
+
paasta_pool: str
|
|
35
|
+
resources: Mapping[str, float]
|
|
36
|
+
start_time: float
|
|
37
|
+
docker_id: str
|
|
38
|
+
pod_name: str
|
|
39
|
+
pod_ip: str
|
|
40
|
+
host_ip: str
|
|
41
|
+
git_sha: str
|
|
42
|
+
config_sha: str
|
|
43
|
+
mesos_container_id: str # Because Mesos task info does not have docker id
|
|
44
|
+
namespace: Optional[str]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_container_info_from_mesos_task(
|
|
48
|
+
task: Task,
|
|
49
|
+
) -> Tuple[Optional[str], Optional[float]]:
|
|
50
|
+
for status in task["statuses"]:
|
|
51
|
+
if status["state"] != "TASK_RUNNING":
|
|
52
|
+
continue
|
|
53
|
+
container_id = (
|
|
54
|
+
status.get("container_status", {}).get("container_id", {}).get("value")
|
|
55
|
+
)
|
|
56
|
+
time_start = status.get("timestamp")
|
|
57
|
+
return container_id, time_start
|
|
58
|
+
return None, None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_paasta_service_instance_from_mesos_task(
|
|
62
|
+
task: Task,
|
|
63
|
+
) -> Tuple[Optional[str], Optional[str]]:
|
|
64
|
+
try:
|
|
65
|
+
docker_params = task["container"].get("docker", {}).get("parameters", [])
|
|
66
|
+
except KeyError:
|
|
67
|
+
return None, None
|
|
68
|
+
service, instance = None, None
|
|
69
|
+
for param in docker_params:
|
|
70
|
+
if param["key"] == "label":
|
|
71
|
+
label = param["value"]
|
|
72
|
+
if label.startswith("paasta_service="):
|
|
73
|
+
service = label.split("=")[1]
|
|
74
|
+
if label.startswith("paasta_instance="):
|
|
75
|
+
instance = label.split("=")[1]
|
|
76
|
+
return service, instance
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
async def get_pool_from_mesos_task(task: Task) -> Optional[str]:
|
|
80
|
+
try:
|
|
81
|
+
attributes = (await task.slave())["attributes"]
|
|
82
|
+
return attributes.get("pool", "default")
|
|
83
|
+
except SlaveDoesNotExist:
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@a_sync.to_blocking
|
|
88
|
+
async def get_mesos_task_allocation_info() -> Iterable[TaskAllocationInfo]:
|
|
89
|
+
tasks = await mesos_tools.get_cached_list_of_running_tasks_from_frameworks()
|
|
90
|
+
info_list = []
|
|
91
|
+
for task in tasks:
|
|
92
|
+
mesos_container_id, start_time = get_container_info_from_mesos_task(task)
|
|
93
|
+
paasta_service, paasta_instance = get_paasta_service_instance_from_mesos_task(
|
|
94
|
+
task
|
|
95
|
+
)
|
|
96
|
+
paasta_pool = await get_pool_from_mesos_task(task)
|
|
97
|
+
info_list.append(
|
|
98
|
+
TaskAllocationInfo(
|
|
99
|
+
paasta_service=paasta_service,
|
|
100
|
+
paasta_instance=paasta_instance,
|
|
101
|
+
container_type=MAIN_CONTAINER_TYPE,
|
|
102
|
+
paasta_pool=paasta_pool,
|
|
103
|
+
resources=task["resources"],
|
|
104
|
+
start_time=start_time,
|
|
105
|
+
docker_id=None,
|
|
106
|
+
pod_name=None,
|
|
107
|
+
pod_ip=None,
|
|
108
|
+
host_ip=None,
|
|
109
|
+
git_sha=None,
|
|
110
|
+
config_sha=None,
|
|
111
|
+
mesos_container_id=mesos_container_id,
|
|
112
|
+
namespace=None,
|
|
113
|
+
)
|
|
114
|
+
)
|
|
115
|
+
return info_list
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def get_all_running_kubernetes_pods(
|
|
119
|
+
kube_client: KubeClient, namespace: str
|
|
120
|
+
) -> Iterable[V1Pod]:
|
|
121
|
+
running = []
|
|
122
|
+
for pod in kubernetes_tools.get_all_pods(kube_client, namespace):
|
|
123
|
+
if kubernetes_tools.get_pod_status(pod) == kubernetes_tools.PodStatus.RUNNING:
|
|
124
|
+
running.append(pod)
|
|
125
|
+
return running
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def get_kubernetes_resource_request_limit(
|
|
129
|
+
resources: V1ResourceRequirements,
|
|
130
|
+
) -> Dict[str, float]:
|
|
131
|
+
if not resources:
|
|
132
|
+
requests: Dict[str, str] = {}
|
|
133
|
+
limits: Dict[str, str] = {}
|
|
134
|
+
else:
|
|
135
|
+
requests = resources.requests or {}
|
|
136
|
+
limits = resources.limits or {}
|
|
137
|
+
|
|
138
|
+
parsed_requests = kubernetes_tools.parse_container_resources(requests)
|
|
139
|
+
parsed_limits = kubernetes_tools.parse_container_resources(limits)
|
|
140
|
+
return {
|
|
141
|
+
"cpus": parsed_requests.cpus,
|
|
142
|
+
"mem": parsed_requests.mem,
|
|
143
|
+
"disk": parsed_requests.disk,
|
|
144
|
+
"cpus_limit": parsed_limits.cpus,
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_pod_pool(
|
|
149
|
+
kube_client: KubeClient,
|
|
150
|
+
pod: V1Pod,
|
|
151
|
+
) -> str:
|
|
152
|
+
node = kubernetes_tools.get_pod_node(kube_client, pod, cache_nodes=True)
|
|
153
|
+
pool = "default"
|
|
154
|
+
if node:
|
|
155
|
+
if node.metadata.labels:
|
|
156
|
+
pool = node.metadata.labels.get("paasta.yelp.com/pool", "default")
|
|
157
|
+
return pool
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def get_kubernetes_metadata(
|
|
161
|
+
pod: V1Pod,
|
|
162
|
+
) -> Tuple[
|
|
163
|
+
Optional[str],
|
|
164
|
+
Optional[str],
|
|
165
|
+
Optional[str],
|
|
166
|
+
Optional[str],
|
|
167
|
+
Optional[str],
|
|
168
|
+
Optional[str],
|
|
169
|
+
Optional[str],
|
|
170
|
+
]:
|
|
171
|
+
labels = pod.metadata.labels or {}
|
|
172
|
+
pod_name = pod.metadata.name
|
|
173
|
+
pod_ip = pod.status.pod_ip
|
|
174
|
+
host_ip = pod.status.host_ip
|
|
175
|
+
service = labels.get("paasta.yelp.com/service")
|
|
176
|
+
instance = labels.get("paasta.yelp.com/instance")
|
|
177
|
+
git_sha = labels.get("paasta.yelp.com/git_sha")
|
|
178
|
+
config_sha = labels.get("paasta.yelp.com/config_sha")
|
|
179
|
+
return service, instance, pod_name, pod_ip, host_ip, git_sha, config_sha
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def get_container_type(container_name: str, instance_name: str) -> str:
|
|
183
|
+
"""
|
|
184
|
+
To differentiate between main service containers and sidecars
|
|
185
|
+
"""
|
|
186
|
+
if instance_name and container_name == kubernetes_tools.sanitise_kubernetes_name(
|
|
187
|
+
instance_name
|
|
188
|
+
):
|
|
189
|
+
return MAIN_CONTAINER_TYPE
|
|
190
|
+
else:
|
|
191
|
+
return container_name
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def get_kubernetes_task_allocation_info(
|
|
195
|
+
namespace: str, client: KubeClient
|
|
196
|
+
) -> Iterable[TaskAllocationInfo]:
|
|
197
|
+
pods = get_all_running_kubernetes_pods(client, namespace)
|
|
198
|
+
info_list = []
|
|
199
|
+
for pod in pods:
|
|
200
|
+
(
|
|
201
|
+
service,
|
|
202
|
+
instance,
|
|
203
|
+
pod_name,
|
|
204
|
+
pod_ip,
|
|
205
|
+
host_ip,
|
|
206
|
+
git_sha,
|
|
207
|
+
config_sha,
|
|
208
|
+
) = get_kubernetes_metadata(pod)
|
|
209
|
+
pool = get_pod_pool(client, pod)
|
|
210
|
+
name_to_info: MutableMapping[str, Any] = {}
|
|
211
|
+
for container in pod.spec.containers:
|
|
212
|
+
name_to_info[container.name] = {
|
|
213
|
+
"resources": get_kubernetes_resource_request_limit(container.resources),
|
|
214
|
+
"container_type": get_container_type(container.name, instance),
|
|
215
|
+
"pod_name": pod_name,
|
|
216
|
+
"pod_ip": pod_ip,
|
|
217
|
+
"host_ip": host_ip,
|
|
218
|
+
"git_sha": git_sha,
|
|
219
|
+
"config_sha": config_sha,
|
|
220
|
+
}
|
|
221
|
+
container_statuses = pod.status.container_statuses or []
|
|
222
|
+
for container in container_statuses:
|
|
223
|
+
if not container.state.running:
|
|
224
|
+
continue
|
|
225
|
+
# docker://abcdef
|
|
226
|
+
docker_id = (
|
|
227
|
+
container.container_id.split("/")[-1]
|
|
228
|
+
if container.container_id
|
|
229
|
+
else None
|
|
230
|
+
)
|
|
231
|
+
update = {
|
|
232
|
+
"docker_id": docker_id,
|
|
233
|
+
"start_time": container.state.running.started_at.timestamp(),
|
|
234
|
+
}
|
|
235
|
+
name_to_info[container.name].update(update)
|
|
236
|
+
for info in name_to_info.values():
|
|
237
|
+
info_list.append(
|
|
238
|
+
TaskAllocationInfo(
|
|
239
|
+
paasta_service=service,
|
|
240
|
+
paasta_instance=instance,
|
|
241
|
+
container_type=info.get("container_type"),
|
|
242
|
+
paasta_pool=pool,
|
|
243
|
+
resources=info.get("resources"),
|
|
244
|
+
start_time=info.get("start_time"),
|
|
245
|
+
docker_id=info.get("docker_id"),
|
|
246
|
+
pod_name=info.get("pod_name"),
|
|
247
|
+
pod_ip=info.get("pod_ip"),
|
|
248
|
+
host_ip=info.get("host_ip"),
|
|
249
|
+
git_sha=info.get("git_sha"),
|
|
250
|
+
config_sha=info.get("config_sha"),
|
|
251
|
+
mesos_container_id=None,
|
|
252
|
+
namespace=namespace,
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
return info_list
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def get_task_allocation_info(
|
|
260
|
+
scheduler: str,
|
|
261
|
+
namespace: str,
|
|
262
|
+
kube_client: Optional[KubeClient],
|
|
263
|
+
) -> Iterable[TaskAllocationInfo]:
|
|
264
|
+
if scheduler == "mesos":
|
|
265
|
+
return get_mesos_task_allocation_info()
|
|
266
|
+
elif scheduler == "kubernetes":
|
|
267
|
+
return get_kubernetes_task_allocation_info(namespace, kube_client)
|
|
268
|
+
else:
|
|
269
|
+
return []
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def parse_args() -> argparse.Namespace:
|
|
273
|
+
parser = argparse.ArgumentParser(description="")
|
|
274
|
+
parser.add_argument(
|
|
275
|
+
"--scheduler",
|
|
276
|
+
help="Scheduler to get task info from",
|
|
277
|
+
dest="scheduler",
|
|
278
|
+
default="kubernetes",
|
|
279
|
+
choices=["mesos", "kubernetes"],
|
|
280
|
+
)
|
|
281
|
+
parser.add_argument(
|
|
282
|
+
"--additional-namespaces-exclude",
|
|
283
|
+
help="full names of namespaces to not fetch allocation info for those that don't match --namespace-prefix-exlude",
|
|
284
|
+
dest="additional_namespaces_exclude",
|
|
285
|
+
nargs="+",
|
|
286
|
+
default=[],
|
|
287
|
+
)
|
|
288
|
+
parser.add_argument(
|
|
289
|
+
"--namespace-prefix",
|
|
290
|
+
help=argparse.SUPPRESS,
|
|
291
|
+
dest="namespace_prefix",
|
|
292
|
+
default="paasta",
|
|
293
|
+
)
|
|
294
|
+
parser.add_argument(
|
|
295
|
+
"--additional-namespaces",
|
|
296
|
+
help=argparse.SUPPRESS,
|
|
297
|
+
dest="additional_namespaces",
|
|
298
|
+
nargs="+",
|
|
299
|
+
# we default this to tron since this is really the only non-paasta-prefix namespaced that is part of paasta
|
|
300
|
+
# and we'd like to not run two cronjobs to get this information :p
|
|
301
|
+
default=["tron"],
|
|
302
|
+
)
|
|
303
|
+
args = parser.parse_args()
|
|
304
|
+
|
|
305
|
+
args.additional_namespaces_exclude = set(args.additional_namespaces_exclude)
|
|
306
|
+
|
|
307
|
+
return args
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def get_unexcluded_namespaces(
|
|
311
|
+
namespaces: List[str], excluded_namespaces: List[str]
|
|
312
|
+
) -> List[str]:
|
|
313
|
+
return [n for n in namespaces if n not in excluded_namespaces]
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def main(args: argparse.Namespace) -> None:
|
|
317
|
+
cluster = load_system_paasta_config().get_cluster()
|
|
318
|
+
kube_client = KubeClient()
|
|
319
|
+
all_namespaces = kubernetes_tools.get_all_namespaces(kube_client)
|
|
320
|
+
for matching_namespace in get_unexcluded_namespaces(
|
|
321
|
+
all_namespaces,
|
|
322
|
+
args.additional_namespaces_exclude,
|
|
323
|
+
):
|
|
324
|
+
display_task_allocation_info(
|
|
325
|
+
cluster, args.scheduler, matching_namespace, kube_client
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def display_task_allocation_info(
|
|
330
|
+
cluster: str,
|
|
331
|
+
scheduler: str,
|
|
332
|
+
namespace: str,
|
|
333
|
+
kube_client: Optional[KubeClient],
|
|
334
|
+
) -> None:
|
|
335
|
+
info_list = get_task_allocation_info(scheduler, namespace, kube_client)
|
|
336
|
+
timestamp = time.time()
|
|
337
|
+
for info in info_list:
|
|
338
|
+
info_dict = info._asdict()
|
|
339
|
+
info_dict["cluster"] = cluster
|
|
340
|
+
info_dict["timestamp"] = timestamp
|
|
341
|
+
print(json.dumps(info_dict))
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
if __name__ == "__main__":
|
|
345
|
+
args = parse_args()
|
|
346
|
+
main(args)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!python
|
|
2
|
+
import argparse
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from kubernetes.client import V1Node
|
|
6
|
+
|
|
7
|
+
from paasta_tools.kubernetes_tools import KUBE_CONFIG_PATH
|
|
8
|
+
from paasta_tools.kubernetes_tools import KUBE_CONFIG_USER_PATH
|
|
9
|
+
from paasta_tools.kubernetes_tools import KubeClient
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def parse_args() -> argparse.Namespace:
|
|
13
|
+
parser = argparse.ArgumentParser(
|
|
14
|
+
description="Karpenter Habitat Corruption Workaround"
|
|
15
|
+
)
|
|
16
|
+
parser.add_argument("-c", "--cluster", required=True)
|
|
17
|
+
parser.add_argument(
|
|
18
|
+
"-k",
|
|
19
|
+
"--kubeconfig",
|
|
20
|
+
default=KUBE_CONFIG_PATH
|
|
21
|
+
if Path(KUBE_CONFIG_PATH).exists()
|
|
22
|
+
else KUBE_CONFIG_USER_PATH,
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"-t", "--context", default=None # -c is taken, so lets use the last letter :p
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"--for-real",
|
|
29
|
+
action="store_true",
|
|
30
|
+
)
|
|
31
|
+
parsed_args = parser.parse_args()
|
|
32
|
+
|
|
33
|
+
if not parsed_args.context:
|
|
34
|
+
if parsed_args.kubeconfig == KUBE_CONFIG_USER_PATH:
|
|
35
|
+
# in the user kubeconfig, context names are just the cluster names
|
|
36
|
+
parsed_args.context = parsed_args.cluster
|
|
37
|
+
else:
|
|
38
|
+
print(
|
|
39
|
+
f"NOTE: no context specified - will use the current context selected in {parsed_args.kubeconfig} "
|
|
40
|
+
"(or the KUBECONTEXT environment variable if set)."
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return parsed_args
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def is_affected_node(node: V1Node) -> bool:
|
|
47
|
+
try:
|
|
48
|
+
int(node.metadata.labels["yelp.com/habitat"])
|
|
49
|
+
return True
|
|
50
|
+
except ValueError:
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def get_desired_habitat(node: V1Node) -> str:
|
|
55
|
+
zone = node.metadata.labels["topology.kubernetes.io/zone"].replace("-", "")
|
|
56
|
+
ecosystem = node.metadata.labels["yelp.com/ecosystem"]
|
|
57
|
+
|
|
58
|
+
return f"{zone}{ecosystem}"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def main():
|
|
62
|
+
args = parse_args()
|
|
63
|
+
client = KubeClient(config_file=args.kubeconfig, context=args.context)
|
|
64
|
+
for node in client.core.list_node().items:
|
|
65
|
+
if not is_affected_node(node):
|
|
66
|
+
continue
|
|
67
|
+
|
|
68
|
+
if args.for_real:
|
|
69
|
+
client.core.patch_node(
|
|
70
|
+
name=node.metadata.name,
|
|
71
|
+
body={
|
|
72
|
+
"metadata": {
|
|
73
|
+
"labels": {
|
|
74
|
+
"yelp.com/habitat": get_desired_habitat(node),
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
)
|
|
79
|
+
else:
|
|
80
|
+
print(
|
|
81
|
+
f"Would have edited {node.metadata.name} in pool={node.metadata.labels['yelp.com/pool']} to have habitat={get_desired_habitat(node)} (from {node.metadata.labels['yelp.com/habitat']})",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
main()
|