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,73 @@
|
|
|
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
|
+
"""
|
|
16
|
+
PaaSTA flink service list jobs, overview and config.
|
|
17
|
+
"""
|
|
18
|
+
from pyramid.view import view_config
|
|
19
|
+
|
|
20
|
+
from paasta_tools.api.views.exception import ApiFailure
|
|
21
|
+
from paasta_tools.flink_tools import cr_id
|
|
22
|
+
from paasta_tools.flink_tools import curl_flink_endpoint
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@view_config(
|
|
26
|
+
route_name="flink.service.instance.jobs", request_method="GET", renderer="json"
|
|
27
|
+
)
|
|
28
|
+
def list_flink_cluster_jobs(request):
|
|
29
|
+
service = request.swagger_data.get("service")
|
|
30
|
+
instance = request.swagger_data.get("instance")
|
|
31
|
+
try:
|
|
32
|
+
return curl_flink_endpoint(cr_id(service, instance), "jobs")
|
|
33
|
+
except ValueError as e:
|
|
34
|
+
raise ApiFailure(e, 500)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@view_config(
|
|
38
|
+
route_name="flink.service.instance.job_details",
|
|
39
|
+
request_method="GET",
|
|
40
|
+
renderer="json",
|
|
41
|
+
)
|
|
42
|
+
def get_flink_cluster_job_details(request):
|
|
43
|
+
service = request.swagger_data.get("service")
|
|
44
|
+
instance = request.swagger_data.get("instance")
|
|
45
|
+
job_id = request.swagger_data.get("job_id")
|
|
46
|
+
try:
|
|
47
|
+
return curl_flink_endpoint(cr_id(service, instance), f"jobs/{job_id}")
|
|
48
|
+
except ValueError as e:
|
|
49
|
+
raise ApiFailure(e, 500)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@view_config(
|
|
53
|
+
route_name="flink.service.instance.overview", request_method="GET", renderer="json"
|
|
54
|
+
)
|
|
55
|
+
def get_flink_cluster_overview(request):
|
|
56
|
+
service = request.swagger_data.get("service")
|
|
57
|
+
instance = request.swagger_data.get("instance")
|
|
58
|
+
try:
|
|
59
|
+
return curl_flink_endpoint(cr_id(service, instance), "overview")
|
|
60
|
+
except ValueError as e:
|
|
61
|
+
raise ApiFailure(e, 500)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@view_config(
|
|
65
|
+
route_name="flink.service.instance.config", request_method="GET", renderer="json"
|
|
66
|
+
)
|
|
67
|
+
def get_flink_cluster_config(request):
|
|
68
|
+
service = request.swagger_data.get("service")
|
|
69
|
+
instance = request.swagger_data.get("instance")
|
|
70
|
+
try:
|
|
71
|
+
return curl_flink_endpoint(cr_id(service, instance), "config")
|
|
72
|
+
except ValueError as e:
|
|
73
|
+
raise ApiFailure(e, 500)
|
|
@@ -0,0 +1,395 @@
|
|
|
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
|
+
"""
|
|
16
|
+
PaaSTA service instance status/start/stop etc.
|
|
17
|
+
"""
|
|
18
|
+
import asyncio
|
|
19
|
+
import logging
|
|
20
|
+
import re
|
|
21
|
+
import traceback
|
|
22
|
+
from typing import Any
|
|
23
|
+
from typing import Dict
|
|
24
|
+
from typing import List
|
|
25
|
+
from typing import Mapping
|
|
26
|
+
from typing import Optional
|
|
27
|
+
|
|
28
|
+
import a_sync
|
|
29
|
+
from pyramid.response import Response
|
|
30
|
+
from pyramid.view import view_config
|
|
31
|
+
|
|
32
|
+
import paasta_tools.mesos.exceptions as mesos_exceptions
|
|
33
|
+
from paasta_tools import tron_tools
|
|
34
|
+
from paasta_tools.api import settings
|
|
35
|
+
from paasta_tools.api.views.exception import ApiFailure
|
|
36
|
+
from paasta_tools.cli.cmds.status import get_actual_deployments
|
|
37
|
+
from paasta_tools.instance import kubernetes as pik
|
|
38
|
+
from paasta_tools.mesos_tools import get_all_frameworks as get_all_mesos_frameworks
|
|
39
|
+
from paasta_tools.utils import compose_job_id
|
|
40
|
+
from paasta_tools.utils import DeploymentVersion
|
|
41
|
+
from paasta_tools.utils import NoConfigurationForServiceError
|
|
42
|
+
from paasta_tools.utils import PAASTA_K8S_INSTANCE_TYPES
|
|
43
|
+
from paasta_tools.utils import TimeoutError
|
|
44
|
+
from paasta_tools.utils import validate_service_instance
|
|
45
|
+
|
|
46
|
+
log = logging.getLogger(__name__)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def tron_instance_status(
|
|
50
|
+
instance_status: Mapping[str, Any], service: str, instance: str, verbose: int
|
|
51
|
+
) -> Mapping[str, Any]:
|
|
52
|
+
status: Dict[str, Any] = {}
|
|
53
|
+
client = tron_tools.get_tron_client()
|
|
54
|
+
short_job, action = instance.split(".")
|
|
55
|
+
job = f"{service}.{short_job}"
|
|
56
|
+
job_content = client.get_job_content(job=job)
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
latest_run_id = client.get_latest_job_run_id(job_content=job_content)
|
|
60
|
+
if latest_run_id is None:
|
|
61
|
+
action_run = {"state": "Hasn't run yet (no job run id found)"}
|
|
62
|
+
else:
|
|
63
|
+
action_run = client.get_action_run(
|
|
64
|
+
job=job, action=action, run_id=latest_run_id
|
|
65
|
+
)
|
|
66
|
+
except Exception as e:
|
|
67
|
+
action_run = {"state": f"Failed to get latest run info: {e}"}
|
|
68
|
+
|
|
69
|
+
# job info
|
|
70
|
+
status["job_name"] = short_job
|
|
71
|
+
status["job_status"] = job_content["status"]
|
|
72
|
+
status["job_schedule"] = "{} {}".format(
|
|
73
|
+
job_content["scheduler"]["type"], job_content["scheduler"]["value"]
|
|
74
|
+
)
|
|
75
|
+
status["job_url"] = (
|
|
76
|
+
tron_tools.get_tron_dashboard_for_cluster(settings.cluster) + f"#job/{job}"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
if action:
|
|
80
|
+
status["action_name"] = action
|
|
81
|
+
if action_run.get("state"):
|
|
82
|
+
status["action_state"] = action_run["state"]
|
|
83
|
+
if action_run.get("start_time"):
|
|
84
|
+
status["action_start_time"] = action_run["start_time"]
|
|
85
|
+
if action_run.get("raw_command"):
|
|
86
|
+
status["action_raw_command"] = action_run["raw_command"]
|
|
87
|
+
if action_run.get("stdout"):
|
|
88
|
+
status["action_stdout"] = "\n".join(action_run["stdout"])
|
|
89
|
+
if action_run.get("stderr"):
|
|
90
|
+
status["action_stderr"] = "\n".join(action_run["stderr"])
|
|
91
|
+
if action_run.get("command"):
|
|
92
|
+
status["action_command"] = action_run["command"]
|
|
93
|
+
|
|
94
|
+
return status
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def legacy_remote_run_filter_frameworks(service, instance, frameworks=None):
|
|
98
|
+
if frameworks is None:
|
|
99
|
+
frameworks = get_all_mesos_frameworks(active_only=True)
|
|
100
|
+
|
|
101
|
+
prefix = f"paasta-remote {service}.{instance}"
|
|
102
|
+
return [f for f in frameworks if f.name.startswith(prefix)]
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def adhoc_instance_status(
|
|
106
|
+
instance_status: Mapping[str, Any], service: str, instance: str, verbose: int
|
|
107
|
+
) -> List[Dict[str, Any]]:
|
|
108
|
+
status = []
|
|
109
|
+
filtered = legacy_remote_run_filter_frameworks(service, instance)
|
|
110
|
+
filtered.sort(key=lambda x: x.name)
|
|
111
|
+
for f in filtered:
|
|
112
|
+
launch_time, run_id = re.match(
|
|
113
|
+
r"paasta-remote [^\s]+ (\w+) (\w+)", f.name
|
|
114
|
+
).groups()
|
|
115
|
+
status.append(
|
|
116
|
+
{"launch_time": launch_time, "run_id": run_id, "framework_id": f.id}
|
|
117
|
+
)
|
|
118
|
+
return status
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
async def _task_result_or_error(future):
|
|
122
|
+
try:
|
|
123
|
+
return {"value": await future}
|
|
124
|
+
except (AttributeError, mesos_exceptions.SlaveDoesNotExist):
|
|
125
|
+
return {"error_message": "None"}
|
|
126
|
+
except TimeoutError:
|
|
127
|
+
return {"error_message": "Timed Out"}
|
|
128
|
+
except Exception:
|
|
129
|
+
return {"error_message": "Unknown"}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def no_configuration_for_service_message(cluster, service, instance):
|
|
133
|
+
return (
|
|
134
|
+
f"No instance named '{compose_job_id(service, instance)}' has been "
|
|
135
|
+
f"configured to run in the {settings.cluster} cluster"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@view_config(
|
|
140
|
+
route_name="service.instance.status", request_method="GET", renderer="json"
|
|
141
|
+
)
|
|
142
|
+
def instance_status(request):
|
|
143
|
+
service = request.swagger_data.get("service")
|
|
144
|
+
instance = request.swagger_data.get("instance")
|
|
145
|
+
verbose = request.swagger_data.get("verbose") or 0
|
|
146
|
+
use_new = request.swagger_data.get("new") or False
|
|
147
|
+
all_namespaces = request.swagger_data.get("all_namespaces") or False
|
|
148
|
+
include_envoy = request.swagger_data.get("include_envoy")
|
|
149
|
+
if include_envoy is None:
|
|
150
|
+
include_envoy = True
|
|
151
|
+
include_mesos = request.swagger_data.get("include_mesos")
|
|
152
|
+
if include_mesos is None:
|
|
153
|
+
include_mesos = True
|
|
154
|
+
|
|
155
|
+
instance_status: Dict[str, Any] = {}
|
|
156
|
+
instance_status["service"] = service
|
|
157
|
+
instance_status["instance"] = instance
|
|
158
|
+
try:
|
|
159
|
+
instance_type = validate_service_instance(
|
|
160
|
+
service, instance, settings.cluster, settings.soa_dir
|
|
161
|
+
)
|
|
162
|
+
except NoConfigurationForServiceError:
|
|
163
|
+
error_message = no_configuration_for_service_message(
|
|
164
|
+
settings.cluster,
|
|
165
|
+
service,
|
|
166
|
+
instance,
|
|
167
|
+
)
|
|
168
|
+
raise ApiFailure(error_message, 404)
|
|
169
|
+
except Exception:
|
|
170
|
+
error_message = traceback.format_exc()
|
|
171
|
+
raise ApiFailure(error_message, 500)
|
|
172
|
+
|
|
173
|
+
if instance_type != "tron":
|
|
174
|
+
try:
|
|
175
|
+
actual_deployments = get_actual_deployments(service, settings.soa_dir)
|
|
176
|
+
except Exception:
|
|
177
|
+
error_message = traceback.format_exc()
|
|
178
|
+
raise ApiFailure(error_message, 500)
|
|
179
|
+
|
|
180
|
+
version = get_deployment_version(actual_deployments, settings.cluster, instance)
|
|
181
|
+
# exit if the deployment key is not found
|
|
182
|
+
if not version:
|
|
183
|
+
error_message = (
|
|
184
|
+
"Deployment key %s not found. Try to execute the corresponding pipeline if it's a fresh instance"
|
|
185
|
+
% ".".join([settings.cluster, instance])
|
|
186
|
+
)
|
|
187
|
+
raise ApiFailure(error_message, 404)
|
|
188
|
+
|
|
189
|
+
instance_status["version"] = version.short_sha_repr()
|
|
190
|
+
# Kept for backwards compatibility
|
|
191
|
+
# TODO: Remove once all clients+clusters updated to use deploymentversion
|
|
192
|
+
instance_status["git_sha"] = version.sha[:8]
|
|
193
|
+
else:
|
|
194
|
+
instance_status["version"] = ""
|
|
195
|
+
instance_status["git_sha"] = ""
|
|
196
|
+
try:
|
|
197
|
+
if instance_type == "adhoc":
|
|
198
|
+
instance_status["adhoc"] = adhoc_instance_status(
|
|
199
|
+
instance_status, service, instance, verbose
|
|
200
|
+
)
|
|
201
|
+
elif pik.can_handle(instance_type):
|
|
202
|
+
instance_status.update(
|
|
203
|
+
pik.instance_status(
|
|
204
|
+
service=service,
|
|
205
|
+
instance=instance,
|
|
206
|
+
verbose=verbose,
|
|
207
|
+
include_envoy=include_envoy,
|
|
208
|
+
use_new=use_new,
|
|
209
|
+
instance_type=instance_type,
|
|
210
|
+
settings=settings,
|
|
211
|
+
all_namespaces=all_namespaces,
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
elif instance_type == "tron":
|
|
215
|
+
instance_status["tron"] = tron_instance_status(
|
|
216
|
+
instance_status, service, instance, verbose
|
|
217
|
+
)
|
|
218
|
+
else:
|
|
219
|
+
error_message = (
|
|
220
|
+
f"Unknown instance_type {instance_type} of {service}.{instance}"
|
|
221
|
+
)
|
|
222
|
+
raise ApiFailure(error_message, 404)
|
|
223
|
+
except Exception:
|
|
224
|
+
error_message = traceback.format_exc()
|
|
225
|
+
raise ApiFailure(error_message, 500)
|
|
226
|
+
|
|
227
|
+
return instance_status
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@view_config(
|
|
231
|
+
route_name="service.instance.set_state", request_method="POST", renderer="json"
|
|
232
|
+
)
|
|
233
|
+
def instance_set_state(
|
|
234
|
+
request,
|
|
235
|
+
) -> None:
|
|
236
|
+
service = request.swagger_data.get("service")
|
|
237
|
+
instance = request.swagger_data.get("instance")
|
|
238
|
+
desired_state = request.swagger_data.get("desired_state")
|
|
239
|
+
|
|
240
|
+
try:
|
|
241
|
+
instance_type = validate_service_instance(
|
|
242
|
+
service, instance, settings.cluster, settings.soa_dir
|
|
243
|
+
)
|
|
244
|
+
except NoConfigurationForServiceError:
|
|
245
|
+
error_message = no_configuration_for_service_message(
|
|
246
|
+
settings.cluster,
|
|
247
|
+
service,
|
|
248
|
+
instance,
|
|
249
|
+
)
|
|
250
|
+
raise ApiFailure(error_message, 404)
|
|
251
|
+
except Exception:
|
|
252
|
+
error_message = traceback.format_exc()
|
|
253
|
+
raise ApiFailure(error_message, 500)
|
|
254
|
+
|
|
255
|
+
if pik.can_set_state(instance_type):
|
|
256
|
+
try:
|
|
257
|
+
pik.set_cr_desired_state(
|
|
258
|
+
kube_client=settings.kubernetes_client,
|
|
259
|
+
service=service,
|
|
260
|
+
instance=instance,
|
|
261
|
+
instance_type=instance_type,
|
|
262
|
+
desired_state=desired_state,
|
|
263
|
+
)
|
|
264
|
+
except RuntimeError as e:
|
|
265
|
+
raise ApiFailure(e, 500)
|
|
266
|
+
else:
|
|
267
|
+
error_message = (
|
|
268
|
+
f"instance_type {instance_type} of {service}.{instance} doesn't "
|
|
269
|
+
"support set_state"
|
|
270
|
+
)
|
|
271
|
+
raise ApiFailure(error_message, 500)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
@view_config(
|
|
275
|
+
route_name="service.instance.bounce_status",
|
|
276
|
+
request_method="GET",
|
|
277
|
+
renderer="json",
|
|
278
|
+
)
|
|
279
|
+
def bounce_status(request):
|
|
280
|
+
service = request.swagger_data.get("service")
|
|
281
|
+
instance = request.swagger_data.get("instance")
|
|
282
|
+
try:
|
|
283
|
+
instance_type = validate_service_instance(
|
|
284
|
+
service, instance, settings.cluster, settings.soa_dir
|
|
285
|
+
)
|
|
286
|
+
except NoConfigurationForServiceError:
|
|
287
|
+
error_message = no_configuration_for_service_message(
|
|
288
|
+
settings.cluster,
|
|
289
|
+
service,
|
|
290
|
+
instance,
|
|
291
|
+
)
|
|
292
|
+
raise ApiFailure(error_message, 404)
|
|
293
|
+
except Exception:
|
|
294
|
+
error_message = traceback.format_exc()
|
|
295
|
+
raise ApiFailure(error_message, 500)
|
|
296
|
+
|
|
297
|
+
if instance_type not in PAASTA_K8S_INSTANCE_TYPES:
|
|
298
|
+
# We are using HTTP 204 to indicate that the instance exists but has
|
|
299
|
+
# no bounce status to be returned. The client should just mark the
|
|
300
|
+
# instance as bounced.
|
|
301
|
+
response = Response()
|
|
302
|
+
response.status_int = 204
|
|
303
|
+
return response
|
|
304
|
+
|
|
305
|
+
try:
|
|
306
|
+
return pik.bounce_status(
|
|
307
|
+
service, instance, settings, is_eks=(instance_type == "eks")
|
|
308
|
+
)
|
|
309
|
+
except NoConfigurationForServiceError:
|
|
310
|
+
# Handle race condition where instance has been removed since the above validation
|
|
311
|
+
error_message = no_configuration_for_service_message(
|
|
312
|
+
settings.cluster,
|
|
313
|
+
service,
|
|
314
|
+
instance,
|
|
315
|
+
)
|
|
316
|
+
raise ApiFailure(error_message, 404)
|
|
317
|
+
except asyncio.TimeoutError:
|
|
318
|
+
raise ApiFailure(
|
|
319
|
+
"Temporary issue fetching bounce status. Please try again.", 599
|
|
320
|
+
)
|
|
321
|
+
except Exception as e:
|
|
322
|
+
error_message = traceback.format_exc()
|
|
323
|
+
if getattr(e, "status", None) == 404:
|
|
324
|
+
# some bounces delete the app & recreate
|
|
325
|
+
# in this case, we relay the 404 and cli handles gracefully
|
|
326
|
+
raise ApiFailure(error_message, 404)
|
|
327
|
+
# for all others, treat as a 500
|
|
328
|
+
raise ApiFailure(error_message, 500)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def add_executor_info(task):
|
|
332
|
+
task._Task__items["executor"] = a_sync.block(task.executor).copy()
|
|
333
|
+
task._Task__items["executor"].pop("tasks", None)
|
|
334
|
+
task._Task__items["executor"].pop("completed_tasks", None)
|
|
335
|
+
task._Task__items["executor"].pop("queued_tasks", None)
|
|
336
|
+
return task
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def add_slave_info(task):
|
|
340
|
+
task._Task__items["slave"] = a_sync.block(task.slave)._MesosSlave__items.copy()
|
|
341
|
+
return task
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def get_deployment_version(
|
|
345
|
+
actual_deployments: Mapping[str, DeploymentVersion], cluster: str, instance: str
|
|
346
|
+
) -> Optional[DeploymentVersion]:
|
|
347
|
+
key = ".".join((cluster, instance))
|
|
348
|
+
return actual_deployments[key] if key in actual_deployments else None
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@view_config(
|
|
352
|
+
route_name="service.instance.mesh_status",
|
|
353
|
+
request_method="GET",
|
|
354
|
+
renderer="json",
|
|
355
|
+
)
|
|
356
|
+
def instance_mesh_status(request):
|
|
357
|
+
service = request.swagger_data.get("service")
|
|
358
|
+
instance = request.swagger_data.get("instance")
|
|
359
|
+
include_envoy = request.swagger_data.get("include_envoy")
|
|
360
|
+
|
|
361
|
+
instance_mesh: Dict[str, Any] = {}
|
|
362
|
+
instance_mesh["service"] = service
|
|
363
|
+
instance_mesh["instance"] = instance
|
|
364
|
+
|
|
365
|
+
try:
|
|
366
|
+
instance_type = validate_service_instance(
|
|
367
|
+
service, instance, settings.cluster, settings.soa_dir
|
|
368
|
+
)
|
|
369
|
+
except NoConfigurationForServiceError:
|
|
370
|
+
error_message = (
|
|
371
|
+
f"No instance named '{compose_job_id(service, instance)}' has been "
|
|
372
|
+
f"configured to run in the {settings.cluster} cluster"
|
|
373
|
+
)
|
|
374
|
+
raise ApiFailure(error_message, 404)
|
|
375
|
+
except Exception:
|
|
376
|
+
error_message = traceback.format_exc()
|
|
377
|
+
raise ApiFailure(error_message, 500)
|
|
378
|
+
|
|
379
|
+
try:
|
|
380
|
+
instance_mesh.update(
|
|
381
|
+
pik.kubernetes_mesh_status(
|
|
382
|
+
service=service,
|
|
383
|
+
instance=instance,
|
|
384
|
+
instance_type=instance_type,
|
|
385
|
+
settings=settings,
|
|
386
|
+
include_envoy=include_envoy,
|
|
387
|
+
)
|
|
388
|
+
)
|
|
389
|
+
except RuntimeError as e:
|
|
390
|
+
raise ApiFailure(str(e), 405)
|
|
391
|
+
except Exception:
|
|
392
|
+
error_message = traceback.format_exc()
|
|
393
|
+
raise ApiFailure(error_message, 500)
|
|
394
|
+
|
|
395
|
+
return instance_mesh
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
"""
|
|
16
|
+
PaaSTA service list (instances) etc.
|
|
17
|
+
"""
|
|
18
|
+
import time
|
|
19
|
+
|
|
20
|
+
from kazoo.exceptions import NoNodeError
|
|
21
|
+
from pyramid.view import view_config
|
|
22
|
+
|
|
23
|
+
from paasta_tools.api.views.exception import ApiFailure
|
|
24
|
+
from paasta_tools.long_running_service_tools import ZK_PAUSE_AUTOSCALE_PATH
|
|
25
|
+
from paasta_tools.utils import ZookeeperPool
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@view_config(
|
|
29
|
+
route_name="service_autoscaler.pause.get", request_method="GET", renderer="json"
|
|
30
|
+
)
|
|
31
|
+
def get_service_autoscaler_pause(request):
|
|
32
|
+
with ZookeeperPool() as zk:
|
|
33
|
+
try:
|
|
34
|
+
pause_until = zk.get(ZK_PAUSE_AUTOSCALE_PATH)[0].decode("utf8")
|
|
35
|
+
except (NoNodeError, ValueError):
|
|
36
|
+
pause_until = "0"
|
|
37
|
+
except Exception as e:
|
|
38
|
+
raise ApiFailure(e, 500)
|
|
39
|
+
|
|
40
|
+
return pause_until
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@view_config(
|
|
44
|
+
route_name="service_autoscaler.pause.post", request_method="POST", renderer="json"
|
|
45
|
+
)
|
|
46
|
+
def update_service_autoscaler_pause(request):
|
|
47
|
+
minutes = request.swagger_data.get("json_body")["minutes"]
|
|
48
|
+
current_time = time.time()
|
|
49
|
+
expiry_time = current_time + minutes * 60
|
|
50
|
+
with ZookeeperPool() as zk:
|
|
51
|
+
try:
|
|
52
|
+
zk.ensure_path(ZK_PAUSE_AUTOSCALE_PATH)
|
|
53
|
+
zk.set(ZK_PAUSE_AUTOSCALE_PATH, str(expiry_time).encode("utf-8"))
|
|
54
|
+
except Exception as e:
|
|
55
|
+
raise ApiFailure(e, 500)
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@view_config(
|
|
60
|
+
route_name="service_autoscaler.pause.delete",
|
|
61
|
+
request_method="DELETE",
|
|
62
|
+
renderer="json",
|
|
63
|
+
)
|
|
64
|
+
def delete_service_autoscaler_pause(request):
|
|
65
|
+
with ZookeeperPool() as zk:
|
|
66
|
+
try:
|
|
67
|
+
zk.ensure_path(ZK_PAUSE_AUTOSCALE_PATH)
|
|
68
|
+
zk.delete(ZK_PAUSE_AUTOSCALE_PATH)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
raise ApiFailure(e, 500)
|
|
71
|
+
return
|
|
@@ -0,0 +1,113 @@
|
|
|
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 traceback
|
|
15
|
+
|
|
16
|
+
from pyramid.view import view_config
|
|
17
|
+
|
|
18
|
+
from paasta_tools.api import settings
|
|
19
|
+
from paasta_tools.api.views.exception import ApiFailure
|
|
20
|
+
from paasta_tools.kubernetes.remote_run import get_max_job_duration_limit
|
|
21
|
+
from paasta_tools.kubernetes.remote_run import remote_run_ready
|
|
22
|
+
from paasta_tools.kubernetes.remote_run import remote_run_start
|
|
23
|
+
from paasta_tools.kubernetes.remote_run import remote_run_stop
|
|
24
|
+
from paasta_tools.kubernetes.remote_run import remote_run_token
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DEFAULT_MAX_DURATION = 60 * 60 # 1 hour
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@view_config(route_name="remote_run.start", request_method="POST", renderer="json")
|
|
31
|
+
def view_remote_run_start(request):
|
|
32
|
+
service = request.swagger_data["service"]
|
|
33
|
+
instance = request.swagger_data["instance"]
|
|
34
|
+
user = request.swagger_data["json_body"]["user"]
|
|
35
|
+
interactive = request.swagger_data["json_body"].get("interactive", True)
|
|
36
|
+
recreate = request.swagger_data["json_body"].get("recreate", False)
|
|
37
|
+
is_toolbox = request.swagger_data["json_body"].get("toolbox", False)
|
|
38
|
+
max_duration = min(
|
|
39
|
+
request.swagger_data["json_body"].get("max_duration", DEFAULT_MAX_DURATION),
|
|
40
|
+
get_max_job_duration_limit(),
|
|
41
|
+
)
|
|
42
|
+
try:
|
|
43
|
+
return remote_run_start(
|
|
44
|
+
service=service,
|
|
45
|
+
instance=instance,
|
|
46
|
+
cluster=settings.cluster,
|
|
47
|
+
user=user,
|
|
48
|
+
interactive=interactive,
|
|
49
|
+
recreate=recreate,
|
|
50
|
+
max_duration=max_duration,
|
|
51
|
+
is_toolbox=is_toolbox,
|
|
52
|
+
)
|
|
53
|
+
except Exception:
|
|
54
|
+
error_message = traceback.format_exc()
|
|
55
|
+
raise ApiFailure(error_message, 500)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@view_config(route_name="remote_run.poll", request_method="GET", renderer="json")
|
|
59
|
+
def view_remote_run_poll(request):
|
|
60
|
+
service = request.swagger_data["service"]
|
|
61
|
+
instance = request.swagger_data["instance"]
|
|
62
|
+
job_name = request.swagger_data["job_name"]
|
|
63
|
+
user = request.swagger_data["user"]
|
|
64
|
+
is_toolbox = request.swagger_data.get("toolbox", False)
|
|
65
|
+
try:
|
|
66
|
+
return remote_run_ready(
|
|
67
|
+
service=service,
|
|
68
|
+
instance=instance,
|
|
69
|
+
cluster=settings.cluster,
|
|
70
|
+
job_name=job_name,
|
|
71
|
+
user=user,
|
|
72
|
+
is_toolbox=is_toolbox,
|
|
73
|
+
)
|
|
74
|
+
except Exception:
|
|
75
|
+
error_message = traceback.format_exc()
|
|
76
|
+
raise ApiFailure(error_message, 500)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@view_config(route_name="remote_run.stop", request_method="POST", renderer="json")
|
|
80
|
+
def view_remote_run_stop(request):
|
|
81
|
+
service = request.swagger_data["service"]
|
|
82
|
+
instance = request.swagger_data["instance"]
|
|
83
|
+
user = request.swagger_data["json_body"]["user"]
|
|
84
|
+
is_toolbox = request.swagger_data["json_body"].get("toolbox", False)
|
|
85
|
+
try:
|
|
86
|
+
return remote_run_stop(
|
|
87
|
+
service=service,
|
|
88
|
+
instance=instance,
|
|
89
|
+
cluster=settings.cluster,
|
|
90
|
+
user=user,
|
|
91
|
+
is_toolbox=is_toolbox,
|
|
92
|
+
)
|
|
93
|
+
except Exception:
|
|
94
|
+
error_message = traceback.format_exc()
|
|
95
|
+
raise ApiFailure(error_message, 500)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@view_config(route_name="remote_run.token", request_method="GET", renderer="json")
|
|
99
|
+
def view_remote_run_token(request):
|
|
100
|
+
service = request.swagger_data["service"]
|
|
101
|
+
instance = request.swagger_data["instance"]
|
|
102
|
+
user = request.swagger_data["user"]
|
|
103
|
+
try:
|
|
104
|
+
token = remote_run_token(
|
|
105
|
+
service=service,
|
|
106
|
+
instance=instance,
|
|
107
|
+
cluster=settings.cluster,
|
|
108
|
+
user=user,
|
|
109
|
+
)
|
|
110
|
+
return {"token": token}
|
|
111
|
+
except Exception:
|
|
112
|
+
error_message = traceback.format_exc()
|
|
113
|
+
raise ApiFailure(error_message, 500)
|