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
17 changes: 5 additions & 12 deletions paasta_tools/kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,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 @@ -2445,22 +2449,11 @@ 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
if self.should_use_metrics_provider(METRICS_PROVIDER_UWSGI):
# UWSGI no longer needs a label to indicate it needs to be scraped as all pods are checked for the uwsgi stats port by our centralized uwsgi-exporter
# But we do still need deploy_group for 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
if self.should_use_metrics_provider(METRICS_PROVIDER_PISCINA):
labels["paasta.yelp.com/deploy_group"] = self.get_deploy_group()
labels["paasta.yelp.com/scrape_piscina_prometheus"] = "true"

if self.should_use_metrics_provider(METRICS_PROVIDER_GUNICORN):
labels["paasta.yelp.com/deploy_group"] = self.get_deploy_group()
labels["paasta.yelp.com/scrape_gunicorn_prometheus"] = "true"

# the default AWS LB Controller behavior is to enable this by-namespace
Expand Down
10 changes: 5 additions & 5 deletions tests/test_kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,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 @@ -1865,12 +1865,12 @@ 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 != METRICS_PROVIDER_UWSGI:
expected_labels[
f"paasta.yelp.com/scrape_{autoscaling_metric_provider}_prometheus"
Expand Down Expand Up @@ -4680,7 +4680,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 @@ -4726,7 +4726,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 @@ -4773,7 +4773,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