diff --git a/paasta_tools/kubernetes_tools.py b/paasta_tools/kubernetes_tools.py index c4b921f837..7165a865b6 100644 --- a/paasta_tools/kubernetes_tools.py +++ b/paasta_tools/kubernetes_tools.py @@ -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()) @@ -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 if self.should_use_metrics_provider(METRICS_PROVIDER_PISCINA): labels["paasta.yelp.com/scrape_piscina_prometheus"] = "true" diff --git a/tests/test_kubernetes_tools.py b/tests/test_kubernetes_tools.py index c9c27342f5..ab86d3037e 100644 --- a/tests/test_kubernetes_tools.py +++ b/tests/test_kubernetes_tools.py @@ -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", @@ -1867,19 +1867,19 @@ 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" + if autoscaling_metric_provider in { + METRICS_PROVIDER_PISCINA, + METRICS_PROVIDER_GUNICORN, + }: + expected_labels[ + f"paasta.yelp.com/scrape_{autoscaling_metric_provider}_prometheus" + ] = "true" + if autoscaling_metric_provider in ( METRICS_PROVIDER_UWSGI, METRICS_PROVIDER_GUNICORN, @@ -4766,7 +4766,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!" @@ -4812,7 +4812,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!" @@ -4859,7 +4859,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!"