Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions paasta_tools/kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,10 @@ def get_pod_template_spec(
"paasta.yelp.com/cluster": self.cluster,
"yelp.com/owner": "compute_infra_platform_experience",
"paasta.yelp.com/managed": "true",
# NOTE: this is mostly here for autoscaling purposes: we use information from the deploy group
# during Prometheus relabeling - but it's not a bad label to have around in general, thus its
# inclusion here
"paasta.yelp.com/deploy_group": self.get_deploy_group(),
}
if service_namespace_config.is_in_smartstack():
labels["paasta.yelp.com/weight"] = str(self.get_weight())
Expand All @@ -2449,25 +2453,7 @@ def get_pod_template_spec(

# not all services use autoscaling, so we label those that do in order to have
# prometheus selectively discover/scrape them
metrics_providers_needing_deploy_group = [
METRICS_PROVIDER_UWSGI,
METRICS_PROVIDER_PISCINA,
METRICS_PROVIDER_GUNICORN,
METRICS_PROVIDER_WORKER_LOAD,
]

if any(
self.should_use_metrics_provider(provider)
for provider in metrics_providers_needing_deploy_group
):
# Deploy group is needed for Prometheus relabeling properly
# This should probably eventually be made into a default label,
# but for now we're fine with it being behind these feature toggles.
# Ideally, we'd also have the docker image here for ease-of-use
# in Prometheus relabeling, but that information is over the
# character limit for k8s labels (63 chars)
labels["paasta.yelp.com/deploy_group"] = self.get_deploy_group()

# NOTE: these are not mutually exclusive as a service could use multiple autoscaling types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+++++++++

if self.should_use_metrics_provider(METRICS_PROVIDER_PISCINA):
labels["paasta.yelp.com/scrape_piscina_prometheus"] = "true"

Expand Down
30 changes: 15 additions & 15 deletions tests/test_kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ def test_get_pod_template_spec(
autoscaling={
"metrics_providers": [{"type": autoscaling_metric_provider}]
},
deploy_group="fake_group",
deploy_group="brentford.fm",
)
autoscaled_deployment = KubernetesDeploymentConfig(
service="kurupt",
Expand Down Expand Up @@ -1867,21 +1867,21 @@ def test_get_pod_template_spec(
"registrations.paasta.yelp.com/kurupt.fm": "true",
"yelp.com/owner": "compute_infra_platform_experience",
"paasta.yelp.com/managed": "true",
"paasta.yelp.com/deploy_group": "brentford.fm",
}
if in_smtstk:
expected_labels["paasta.yelp.com/weight"] = "10"

if autoscaling_metric_provider:
expected_labels["paasta.yelp.com/deploy_group"] = "fake_group"
if autoscaling_metric_provider in (
METRICS_PROVIDER_PISCINA,
METRICS_PROVIDER_GUNICORN,
):
expected_labels[
f"paasta.yelp.com/scrape_{autoscaling_metric_provider}_prometheus"
] = "true"
elif autoscaling_metric_provider == METRICS_PROVIDER_WORKER_LOAD:
expected_labels["paasta.yelp.com/scrape_gunicorn_prometheus"] = "true"
if autoscaling_metric_provider in (
METRICS_PROVIDER_PISCINA,
METRICS_PROVIDER_GUNICORN,
):
expected_labels[
f"paasta.yelp.com/scrape_{autoscaling_metric_provider}_prometheus"
] = "true"
elif autoscaling_metric_provider == METRICS_PROVIDER_WORKER_LOAD:
expected_labels["paasta.yelp.com/scrape_gunicorn_prometheus"] = "true"

if autoscaling_metric_provider in (
METRICS_PROVIDER_UWSGI,
METRICS_PROVIDER_GUNICORN,
Expand Down Expand Up @@ -4768,7 +4768,7 @@ def test_warning_big_bounce_default_config():
job_config.format_kubernetes_app().spec.template.metadata.labels[
"paasta.yelp.com/config_sha"
]
== "config84789e0b"
== "config477c36f2"
), "If this fails, just change the constant in this test, but be aware that deploying this change will cause every service to bounce!"


Expand Down Expand Up @@ -4814,7 +4814,7 @@ def test_warning_big_bounce_routable_pod():
job_config.format_kubernetes_app().spec.template.metadata.labels[
"paasta.yelp.com/config_sha"
]
== "config46a479f2"
== "config8f26372a"
), "If this fails, just change the constant in this test, but be aware that deploying this change will cause every smartstack-registered service to bounce!"


Expand Down Expand Up @@ -4861,7 +4861,7 @@ def test_warning_big_bounce_common_config():
job_config.format_kubernetes_app().spec.template.metadata.labels[
"paasta.yelp.com/config_sha"
]
== "confige61d940f"
== "configcf829e28"
), "If this fails, just change the constant in this test, but be aware that deploying this change will cause every service to bounce!"


Expand Down