From 1de809c847a77af00414dfb38c0ea3179a177173 Mon Sep 17 00:00:00 2001 From: pgvishnuram Date: Tue, 26 Oct 2021 18:39:36 +0530 Subject: [PATCH 1/2] Add Labels to cleanup pods --- chart/templates/cleanup/cleanup-cronjob.yaml | 7 +++++++ chart/tests/test_cleanup_pods.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/chart/templates/cleanup/cleanup-cronjob.yaml b/chart/templates/cleanup/cleanup-cronjob.yaml index d3b8f93be3de6..3d512c4b7bb33 100644 --- a/chart/templates/cleanup/cleanup-cronjob.yaml +++ b/chart/templates/cleanup/cleanup-cronjob.yaml @@ -48,6 +48,13 @@ spec: backoffLimit: 1 template: metadata: + labels: + tier: airflow + component: airflow-cleanup-pods + release: {{ .Release.Name }} +{{- with .Values.labels }} +{{ toYaml . | indent 12 }} +{{- end }} annotations: sidecar.istio.io/inject: "false" spec: diff --git a/chart/tests/test_cleanup_pods.py b/chart/tests/test_cleanup_pods.py index 7727e9fd600e3..1e91378b88442 100644 --- a/chart/tests/test_cleanup_pods.py +++ b/chart/tests/test_cleanup_pods.py @@ -158,3 +158,21 @@ def test_command_and_args_overrides_are_templated(self): "spec.jobTemplate.spec.template.spec.containers[0].command", docs[0] ) assert ["Helm"] == jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].args", docs[0]) + + def test_should_set_labels_to_jobs_from_cronjob(self): + docs = render_chart( + values={ + "cleanup": {"enabled": True}, + "labels": {"project": "airflow"}, + }, + show_only=["templates/cleanup/cleanup-cronjob.yaml"], + ) + + print(docs[0]) + + assert { + "tier": "airflow", + "component": "airflow-cleanup-pods", + "release": "RELEASE-NAME", + "project": "airflow", + } == jmespath.search("spec.jobTemplate.spec.template.metadata.labels", docs[0]) From 23e9265ce2b3edd06ac629f357aabd48b08b57ad Mon Sep 17 00:00:00 2001 From: pgvishnuram <81585115+pgvishnuram@users.noreply.github.com> Date: Tue, 26 Oct 2021 22:24:23 +0530 Subject: [PATCH 2/2] Update chart/tests/test_cleanup_pods.py forgot to remove print statement Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> --- chart/tests/test_cleanup_pods.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/chart/tests/test_cleanup_pods.py b/chart/tests/test_cleanup_pods.py index 1e91378b88442..8e902bcc96b66 100644 --- a/chart/tests/test_cleanup_pods.py +++ b/chart/tests/test_cleanup_pods.py @@ -168,8 +168,6 @@ def test_should_set_labels_to_jobs_from_cronjob(self): show_only=["templates/cleanup/cleanup-cronjob.yaml"], ) - print(docs[0]) - assert { "tier": "airflow", "component": "airflow-cleanup-pods",