From 8572ea9142a9c1c37a3df016181d6beae3519d2e Mon Sep 17 00:00:00 2001 From: gibsondan Date: Thu, 1 Aug 2024 12:15:55 -0700 Subject: [PATCH] Add a dagster/job_name tag to ECS run launcher tasks (#23364) Summary: Resolves https://github.com/dagster-io/dagster/issues/14939. ## Summary & Motivation ## How I Tested These Changes --- .../libraries/dagster-aws/dagster_aws/ecs/launcher.py | 6 +++++- .../ecs_tests/launcher_tests/test_launching.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/python_modules/libraries/dagster-aws/dagster_aws/ecs/launcher.py b/python_modules/libraries/dagster-aws/dagster_aws/ecs/launcher.py index 118adc41068cd..999cd3ea400f7 100644 --- a/python_modules/libraries/dagster-aws/dagster_aws/ecs/launcher.py +++ b/python_modules/libraries/dagster-aws/dagster_aws/ecs/launcher.py @@ -346,7 +346,11 @@ def build_ecs_tags_for_run_task(self, run, container_context: EcsContainerContex if any(tag["key"] == "dagster/run_id" for tag in container_context.run_ecs_tags): raise Exception("Cannot override system ECS tag: dagster/run_id") - return [{"key": "dagster/run_id", "value": run.run_id}, *container_context.run_ecs_tags] + return [ + {"key": "dagster/run_id", "value": run.run_id}, + {"key": "dagster/job_name", "value": run.job_name}, + *container_context.run_ecs_tags, + ] def _get_run_tags(self, run_id): run = self._instance.get_run_by_id(run_id) diff --git a/python_modules/libraries/dagster-aws/dagster_aws_tests/ecs_tests/launcher_tests/test_launching.py b/python_modules/libraries/dagster-aws/dagster_aws_tests/ecs_tests/launcher_tests/test_launching.py index b398ea05adeff..75f1ce8de2898 100644 --- a/python_modules/libraries/dagster-aws/dagster_aws_tests/ecs_tests/launcher_tests/test_launching.py +++ b/python_modules/libraries/dagster-aws/dagster_aws_tests/ecs_tests/launcher_tests/test_launching.py @@ -88,6 +88,11 @@ def test_default_launcher( ) assert ecs.list_tags_for_resource(resourceArn=task_arn)["tags"][0]["value"] == run.run_id + assert ( + ecs.list_tags_for_resource(resourceArn=task_arn)["tags"][1]["key"] == "dagster/job_name" + ) + assert ecs.list_tags_for_resource(resourceArn=task_arn)["tags"][1]["value"] == run.job_name + # We set job-specific overides overrides = task["overrides"]["containerOverrides"] assert len(overrides) == 1