Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Yelp/paasta into u/vit/tron-1636-…
Browse files Browse the repository at this point in the history
…add-secret-volume
  • Loading branch information
Molaire committed Jun 1, 2023
2 parents e9ccd71 + 92d8d57 commit 9a0fe06
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
paasta-tools (0.174.7) xenial; urgency=medium

* 0.174.7 tagged with 'make release'
Commit: Merge branch "u/krall/uwsgi_autoscaling_namespace"

-- Evan Krall <[email protected]> Tue, 30 May 2023 14:48:11 -0700

paasta-tools (0.174.6) xenial; urgency=medium

* 0.174.6 tagged with 'make release'
Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# setup phase, the dependencies may not exist on disk yet.
#
# Don't bump version manually. See `make release` docs in ./Makefile
__version__ = "0.174.6"
__version__ = "0.174.7"
28 changes: 22 additions & 6 deletions paasta_tools/setup_prometheus_adapter_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,18 @@ def create_instance_uwsgi_scaling_rule(
offset_multiplier = load_system_paasta_config().get_uwsgi_offset_multiplier()

deployment_name = get_kubernetes_app_name(service=service, instance=instance)

# In order for autoscaling to work safely while a service migrates from one namespace to another, the HPA needs to
# make sure that the deployment in the new namespace is scaled up enough to handle _all_ the load.
# This is because once the new deployment is 100% healthy, cleanup_kubernetes_job will delete the deployment out of
# the old namespace all at once, suddenly putting all the load onto the deployment in the new namespace.
# To ensure this, we must:
# - DO NOT filter on namespace in worker_filter_terms (which is used when calculating desired_instances).
# - DO filter on namespace in replica_filter_terms (which is used to calculate current_replicas).
# This makes sure that desired_instances includes load from all namespaces, but that the scaling ratio calculated
# by (desired_instances / current_replicas) is meaningful for each namespace.
worker_filter_terms = f"paasta_cluster='{paasta_cluster}',paasta_service='{service}',paasta_instance='{instance}'"
replica_filter_terms = (
f"paasta_cluster='{paasta_cluster}',deployment='{deployment_name}'"
)
replica_filter_terms = f"paasta_cluster='{paasta_cluster}',deployment='{deployment_name}',namespace='{namespace}'"

current_replicas = f"""
sum(
Expand Down Expand Up @@ -323,10 +331,18 @@ def create_instance_piscina_scaling_rule(
DEFAULT_PISCINA_AUTOSCALING_MOVING_AVERAGE_WINDOW,
)
deployment_name = get_kubernetes_app_name(service=service, instance=instance)

# In order for autoscaling to work safely while a service migrates from one namespace to another, the HPA needs to
# make sure that the deployment in the new namespace is scaled up enough to handle _all_ the load.
# This is because once the new deployment is 100% healthy, cleanup_kubernetes_job will delete the deployment out of
# the old namespace all at once, suddenly putting all the load onto the deployment in the new namespace.
# To ensure this, we must:
# - DO NOT filter on namespace in worker_filter_terms (which is used when calculating desired_instances).
# - DO filter on namespace in replica_filter_terms (which is used to calculate current_replicas).
# This makes sure that desired_instances includes load from all namespaces, but that the scaling ratio calculated
# by (desired_instances / current_replicas) is meaningful for each namespace.
worker_filter_terms = f"paasta_cluster='{paasta_cluster}',paasta_service='{service}',paasta_instance='{instance}'"
replica_filter_terms = (
f"paasta_cluster='{paasta_cluster}',deployment='{deployment_name}'"
)
replica_filter_terms = f"paasta_cluster='{paasta_cluster}',deployment='{deployment_name}',namespace='{namespace}'"

current_replicas = f"""
sum(
Expand Down
2 changes: 1 addition & 1 deletion yelp_package/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Edit this release and run "make release"
RELEASE=0.174.6
RELEASE=0.174.7

SHELL=/bin/bash

Expand Down

0 comments on commit 9a0fe06

Please sign in to comment.