From d11606dafafcb404b1a6c1613dbcdeb8844d93a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20P=C3=A1ez?= Date: Mon, 18 Jul 2022 19:40:14 +0200 Subject: [PATCH] Add revisionHistoryLimit to all deployments --- .../dag-processor-deployment.yaml | 4 + chart/templates/flower/flower-deployment.yaml | 4 + .../pgbouncer/pgbouncer-deployment.yaml | 4 + .../scheduler/scheduler-deployment.yaml | 4 + chart/templates/statsd/statsd-deployment.yaml | 4 + .../triggerer/triggerer-deployment.yaml | 4 + .../webserver/webserver-deployment.yaml | 4 + .../templates/workers/worker-deployment.yaml | 4 + chart/values.schema.json | 81 +++++++++++++++++++ chart/values.yaml | 19 +++++ tests/charts/test_dag_processor.py | 18 +++++ tests/charts/test_flower.py | 19 +++++ tests/charts/test_pgbouncer.py | 18 +++++ tests/charts/test_scheduler.py | 14 ++++ tests/charts/test_statsd.py | 15 ++++ tests/charts/test_triggerer.py | 18 +++++ tests/charts/test_webserver.py | 14 ++++ tests/charts/test_worker.py | 14 ++++ 18 files changed, 262 insertions(+) diff --git a/chart/templates/dag-processor/dag-processor-deployment.yaml b/chart/templates/dag-processor/dag-processor-deployment.yaml index 7ed7802c45a8a..485859456a96a 100644 --- a/chart/templates/dag-processor/dag-processor-deployment.yaml +++ b/chart/templates/dag-processor/dag-processor-deployment.yaml @@ -24,6 +24,7 @@ {{- $affinity := or .Values.dagProcessor.affinity .Values.affinity }} {{- $tolerations := or .Values.dagProcessor.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.dagProcessor.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.dagProcessor.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "airflowSecurityContext" (list . .Values.dagProcessor) }} kind: Deployment apiVersion: apps/v1 @@ -40,6 +41,9 @@ metadata: {{- end }} spec: replicas: {{ .Values.dagProcessor.replicas }} + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} selector: matchLabels: tier: airflow diff --git a/chart/templates/flower/flower-deployment.yaml b/chart/templates/flower/flower-deployment.yaml index 18ca45ed5ee2b..08c879d21639e 100644 --- a/chart/templates/flower/flower-deployment.yaml +++ b/chart/templates/flower/flower-deployment.yaml @@ -24,6 +24,7 @@ {{- $affinity := or .Values.flower.affinity .Values.affinity }} {{- $tolerations := or .Values.flower.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.flower.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.flower.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "airflowSecurityContext" (list . .Values.flower) }} kind: Deployment apiVersion: apps/v1 @@ -40,6 +41,9 @@ metadata: {{- end }} spec: replicas: 1 + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} selector: matchLabels: tier: airflow diff --git a/chart/templates/pgbouncer/pgbouncer-deployment.yaml b/chart/templates/pgbouncer/pgbouncer-deployment.yaml index fffbb99e77cac..fb8c784842af0 100644 --- a/chart/templates/pgbouncer/pgbouncer-deployment.yaml +++ b/chart/templates/pgbouncer/pgbouncer-deployment.yaml @@ -23,6 +23,7 @@ {{- $affinity := or .Values.pgbouncer.affinity .Values.affinity }} {{- $tolerations := or .Values.pgbouncer.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.pgbouncer.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.pgbouncer.revisionHistoryLimit .Values.revisionHistoryLimit }} kind: Deployment apiVersion: apps/v1 metadata: @@ -38,6 +39,9 @@ metadata: {{- end }} spec: replicas: 1 + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} strategy: rollingUpdate: maxSurge: 1 diff --git a/chart/templates/scheduler/scheduler-deployment.yaml b/chart/templates/scheduler/scheduler-deployment.yaml index 1b47af5fec0c4..8aaa24e2036e9 100644 --- a/chart/templates/scheduler/scheduler-deployment.yaml +++ b/chart/templates/scheduler/scheduler-deployment.yaml @@ -34,6 +34,7 @@ {{- $affinity := or .Values.scheduler.affinity .Values.affinity }} {{- $tolerations := or .Values.scheduler.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.scheduler.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.scheduler.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "airflowSecurityContext" (list . .Values.scheduler) }} kind: {{ if $stateful }}StatefulSet{{ else }}Deployment{{ end }} @@ -54,6 +55,9 @@ spec: serviceName: {{ .Release.Name }}-scheduler {{- end }} replicas: {{ .Values.scheduler.replicas }} + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} {{- if and $stateful .Values.scheduler.updateStrategy }} updateStrategy: {{- toYaml .Values.scheduler.updateStrategy | nindent 4 }} diff --git a/chart/templates/statsd/statsd-deployment.yaml b/chart/templates/statsd/statsd-deployment.yaml index 9c2036b721437..7d83099feb35c 100644 --- a/chart/templates/statsd/statsd-deployment.yaml +++ b/chart/templates/statsd/statsd-deployment.yaml @@ -23,6 +23,7 @@ {{- $affinity := or .Values.statsd.affinity .Values.affinity }} {{- $tolerations := or .Values.statsd.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.statsd.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.statsd.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "localSecurityContext" .Values.statsd }} kind: Deployment apiVersion: apps/v1 @@ -39,6 +40,9 @@ metadata: {{- end }} spec: replicas: 1 + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} selector: matchLabels: tier: airflow diff --git a/chart/templates/triggerer/triggerer-deployment.yaml b/chart/templates/triggerer/triggerer-deployment.yaml index b6ad5dca1dd8a..7842e76de885f 100644 --- a/chart/templates/triggerer/triggerer-deployment.yaml +++ b/chart/templates/triggerer/triggerer-deployment.yaml @@ -24,6 +24,7 @@ {{- $affinity := or .Values.triggerer.affinity .Values.affinity }} {{- $tolerations := or .Values.triggerer.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.triggerer.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.triggerer.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "airflowSecurityContext" (list . .Values.triggerer) }} kind: Deployment apiVersion: apps/v1 @@ -40,6 +41,9 @@ metadata: {{- end }} spec: replicas: {{ .Values.triggerer.replicas }} + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} selector: matchLabels: tier: airflow diff --git a/chart/templates/webserver/webserver-deployment.yaml b/chart/templates/webserver/webserver-deployment.yaml index c8d8e6ad15845..9487df1a404ce 100644 --- a/chart/templates/webserver/webserver-deployment.yaml +++ b/chart/templates/webserver/webserver-deployment.yaml @@ -22,6 +22,7 @@ {{- $affinity := or .Values.webserver.affinity .Values.affinity }} {{- $tolerations := or .Values.webserver.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.webserver.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.webserver.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "airflowSecurityContext" (list . .Values.webserver) }} kind: Deployment apiVersion: apps/v1 @@ -38,6 +39,9 @@ metadata: {{- end }} spec: replicas: {{ .Values.webserver.replicas }} + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} strategy: {{- if .Values.webserver.strategy }} {{- toYaml .Values.webserver.strategy | nindent 4 }} diff --git a/chart/templates/workers/worker-deployment.yaml b/chart/templates/workers/worker-deployment.yaml index a1f51de0f5725..501ca380e7fdd 100644 --- a/chart/templates/workers/worker-deployment.yaml +++ b/chart/templates/workers/worker-deployment.yaml @@ -24,6 +24,7 @@ {{- $affinity := or .Values.workers.affinity .Values.affinity }} {{- $tolerations := or .Values.workers.tolerations .Values.tolerations }} {{- $topologySpreadConstraints := or .Values.workers.topologySpreadConstraints .Values.topologySpreadConstraints }} +{{- $revisionHistoryLimit := or .Values.workers.revisionHistoryLimit .Values.revisionHistoryLimit }} {{- $securityContext := include "airflowSecurityContext" (list . .Values.workers) }} kind: {{ if $persistence }}StatefulSet{{ else }}Deployment{{ end }} apiVersion: apps/v1 @@ -43,6 +44,9 @@ spec: serviceName: {{ .Release.Name }}-worker {{- end }} replicas: {{ .Values.workers.replicas }} + {{- if $revisionHistoryLimit }} + revisionHistoryLimit: {{ $revisionHistoryLimit }} + {{- end }} selector: matchLabels: tier: airflow diff --git a/chart/values.schema.json b/chart/values.schema.json index ffc008e67ba86..b24e8fcf0c7cc 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -29,6 +29,15 @@ "default": "", "x-docsSection": null }, + "revisionHistoryLimit": { + "description": "Global number of old replicasets to retain. Can be overridden by each deployment's revisionHistoryLimit", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "nameOverride": { "description": "Override the name of the chart", "type": "string", @@ -1139,6 +1148,15 @@ "type": "integer", "default": 1 }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use when running Airflow workers (templated).", "type": [ @@ -1593,6 +1611,15 @@ "type": "integer", "default": 1 }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use when running the Airflow scheduler (templated).", "type": [ @@ -1934,6 +1961,15 @@ "type": "integer", "default": 1 }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use when running the Airflow triggerer (templated).", "type": [ @@ -2192,6 +2228,15 @@ "type": "integer", "default": 1 }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use when running the Airflow dag processor (templated).", "type": [ @@ -2831,6 +2876,15 @@ "type": "integer", "default": 1 }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use when running the Airflow webserver (templated).", "type": [ @@ -3244,6 +3298,15 @@ "type": "boolean", "default": false }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use when running flower (templated).", "type": [ @@ -3565,6 +3628,15 @@ "type": "boolean", "default": true }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "extraNetworkPolicies": { "description": "Additional NetworkPolicies as needed.", "type": "array", @@ -3711,6 +3783,15 @@ "x-docsSection": "Common", "default": false }, + "revisionHistoryLimit": { + "description": "Number of old replicasets to retain.", + "type": [ + "integer", + "null" + ], + "default": null, + "x-docsSection": null + }, "command": { "description": "Command to use for PgBouncer (templated).", "type": [ diff --git a/chart/values.yaml b/chart/values.yaml index 934448cd4c84d..f795e0f02a436 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -28,6 +28,9 @@ nameOverride: "" # Provide a Kubernetes version (used for API Version selection) to override the auto-detected version kubeVersionOverride: "" +# Max number of old replicasets to retain. Can be overridden by each deployment's revisionHistoryLimit +revisionHistoryLimit: ~ + # User and group of airflow user uid: 50000 gid: 0 @@ -431,6 +434,8 @@ kerberos: workers: # Number of airflow celery workers in StatefulSet replicas: 1 + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use when running Airflow workers (templated). command: ~ @@ -605,6 +610,8 @@ scheduler: # Airflow 2.0 allows users to run multiple schedulers, # However this feature is only recommended for MySQL 8+ and Postgres replicas: 1 + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use when running the Airflow scheduler (templated). command: ~ @@ -853,6 +860,8 @@ webserver: # Number of webservers replicas: 1 + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use when running the Airflow webserver (templated). command: ~ @@ -986,6 +995,8 @@ triggerer: enabled: true # Number of airflow triggerers in the deployment replicas: 1 + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use when running Airflow triggerers (templated). command: ~ @@ -1076,6 +1087,8 @@ dagProcessor: enabled: false # Number of airflow dag processors in the deployment replicas: 1 + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use when running Airflow dag processors (templated). command: ~ @@ -1166,6 +1179,8 @@ flower: # Enable flower. # If True, and using CeleryExecutor/CeleryKubernetesExecutor, will deploy flower app. enabled: false + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use when running flower (templated). command: ~ @@ -1257,6 +1272,8 @@ flower: # StatsD settings statsd: enabled: true + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Create ServiceAccount serviceAccount: @@ -1304,6 +1321,8 @@ statsd: pgbouncer: # Enable PgBouncer enabled: false + # Max number of old replicasets to retain + revisionHistoryLimit: ~ # Command to use for PgBouncer(templated). command: ["pgbouncer", "-u", "nobody", "/etc/pgbouncer/pgbouncer.ini"] # Args to use for PgBouncer(templated). diff --git a/tests/charts/test_dag_processor.py b/tests/charts/test_dag_processor.py index fa0c83d9e3011..11367aa6e0b01 100644 --- a/tests/charts/test_dag_processor.py +++ b/tests/charts/test_dag_processor.py @@ -372,6 +372,24 @@ def test_default_command_and_args(self): "spec.template.spec.containers[0].args", docs[0] ) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = { + "dagProcessor": { + "enabled": True, + } + } + if revision_history_limit: + values['dagProcessor']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/dag-processor/dag-processor-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + @parameterized.expand( [ (None, None), diff --git a/tests/charts/test_flower.py b/tests/charts/test_flower.py index 434a32cdaa553..52f99f11211eb 100644 --- a/tests/charts/test_flower.py +++ b/tests/charts/test_flower.py @@ -17,6 +17,7 @@ import jmespath import pytest +from parameterized import parameterized from tests.charts.helm_template_generator import render_chart @@ -44,6 +45,24 @@ def test_create_flower(self, executor, flower_enabled, created): assert "RELEASE-NAME-flower" == jmespath.search("metadata.name", docs[0]) assert "flower" == jmespath.search("spec.template.spec.containers[0].name", docs[0]) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = { + "flower": { + "enabled": True, + } + } + if revision_history_limit: + values['flower']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/flower/flower-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + @pytest.mark.parametrize( "airflow_version, expected_arg", [ diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index c0dee4ea59d6a..8783b509b0137 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -96,6 +96,24 @@ def test_pgbouncer_service_extra_annotations(self): "foo": "bar", } == jmespath.search("metadata.annotations", docs[0]) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = { + "pgbouncer": { + "enabled": True, + } + } + if revision_history_limit: + values['pgbouncer']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + def test_should_create_valid_affinity_tolerations_and_node_selector(self): docs = render_chart( values={ diff --git a/tests/charts/test_scheduler.py b/tests/charts/test_scheduler.py index b163bea3e3763..c6cc17381f35f 100644 --- a/tests/charts/test_scheduler.py +++ b/tests/charts/test_scheduler.py @@ -115,6 +115,20 @@ def test_should_add_extra_volume_and_extra_volume_mount(self): "spec.template.spec.containers[0].volumeMounts[*].name", docs[0] ) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = {"scheduler": {}} + if revision_history_limit: + values['scheduler']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/scheduler/scheduler-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + def test_should_create_valid_affinity_tolerations_and_node_selector(self): docs = render_chart( values={ diff --git a/tests/charts/test_statsd.py b/tests/charts/test_statsd.py index d6c9efb7dc171..725340a3cf346 100644 --- a/tests/charts/test_statsd.py +++ b/tests/charts/test_statsd.py @@ -18,6 +18,7 @@ import unittest import jmespath +from parameterized import parameterized from tests.charts.helm_template_generator import render_chart @@ -51,6 +52,20 @@ def test_should_add_volume_and_volume_mount_when_exist_extra_mappings(self): "subPath": "mappings.yml", } in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = {"statsd": {"enabled": True}} + if revision_history_limit: + values['statsd']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/statsd/statsd-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + def test_should_create_valid_affinity_tolerations_and_node_selector(self): docs = render_chart( values={ diff --git a/tests/charts/test_triggerer.py b/tests/charts/test_triggerer.py index 0cc18c7687011..0436a861e230d 100644 --- a/tests/charts/test_triggerer.py +++ b/tests/charts/test_triggerer.py @@ -51,6 +51,24 @@ def test_can_be_disabled(self): assert 0 == len(docs) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = { + "triggerer": { + "enabled": True, + } + } + if revision_history_limit: + values['triggerer']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/triggerer/triggerer-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + def test_disable_wait_for_migration(self): docs = render_chart( values={ diff --git a/tests/charts/test_webserver.py b/tests/charts/test_webserver.py index b15a50d181ff0..0664fa2e43c0b 100644 --- a/tests/charts/test_webserver.py +++ b/tests/charts/test_webserver.py @@ -60,6 +60,20 @@ def test_should_add_path_to_liveness_and_readiness_probes(self): == "/mypath/path/health" ) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = {"webserver": {}} + if revision_history_limit: + values['webserver']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/webserver/webserver-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + @parameterized.expand( [ ({"config": {"webserver": {"base_url": ""}}},), diff --git a/tests/charts/test_worker.py b/tests/charts/test_worker.py index 017429bfede6c..3f3a2572e252e 100644 --- a/tests/charts/test_worker.py +++ b/tests/charts/test_worker.py @@ -46,6 +46,20 @@ def test_worker_kind(self, executor, persistence, kind): assert kind == jmespath.search("kind", docs[0]) + @parameterized.expand([(8, 10), (10, 8), (8, None), (None, 10), (None, None)]) + def test_revision_history_limit(self, revision_history_limit, global_revision_history_limit): + values = {"workers": {}} + if revision_history_limit: + values['workers']['revisionHistoryLimit'] = revision_history_limit + if global_revision_history_limit: + values['revisionHistoryLimit'] = global_revision_history_limit + docs = render_chart( + values=values, + show_only=["templates/workers/worker-deployment.yaml"], + ) + expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit + assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result + def test_should_add_extra_containers(self): docs = render_chart( values={