You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2024/08/04 19:53:57 UTC
(airflow) branch main updated: enable AIRFLOW__CELERY__BROKER_URL_CMD when passwordSecretName is true (#40270)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0783ded3c5 enable AIRFLOW__CELERY__BROKER_URL_CMD when passwordSecretName is true (#40270)
0783ded3c5 is described below
commit 0783ded3c520d036c6c50e622a7cc88725b498d1
Author: Jaejun <63...@users.noreply.github.com>
AuthorDate: Mon Aug 5 04:53:51 2024 +0900
enable AIRFLOW__CELERY__BROKER_URL_CMD when passwordSecretName is true (#40270)
---
chart/templates/check-values.yaml | 14 ++++++++++++--
helm_tests/other/test_redis.py | 28 +++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/chart/templates/check-values.yaml b/chart/templates/check-values.yaml
index 7e7871abb2..b1c2724050 100644
--- a/chart/templates/check-values.yaml
+++ b/chart/templates/check-values.yaml
@@ -30,8 +30,18 @@ The sole purpose of this yaml file is it to check the values file is consistent
{{- if or (eq .Values.executor "CeleryExecutor") (eq .Values.executor "CeleryKubernetesExecutor") }}
{{- if .Values.redis.enabled }}
- {{- if and .Values.redis.passwordSecretName (not .Values.data.brokerUrlSecretName) }}
- {{ required "When using the internal redis of the chart and setting the value redis.passwordSecretName, you must also set the value data.brokerUrlSecretName." nil }}
+ {{- if .Values.redis.passwordSecretName }}
+ {{- $existedBrokerUrlCmd := false }}
+ {{- range .Values.env }}
+ {{- if eq .name "AIRFLOW__CELERY__BROKER_URL_CMD" }}
+ {{- $existedBrokerUrlCmd = true }}
+ {{- break -}}
+ {{- end }}
+ {{- end }}
+
+ {{- if not (or .Values.data.brokerUrlSecretName $existedBrokerUrlCmd) }}
+ {{ required "When using the internal redis of the chart and setting the value redis.passwordSecretName, you must also set the value data.brokerUrlSecretName or AIRFLOW__CELERY__BROKER_URL_CMD in env." nil }}
+ {{- end }}
{{- end }}
{{- if and .Values.redis.passwordSecretName .Values.redis.password }}
diff --git a/helm_tests/other/test_redis.py b/helm_tests/other/test_redis.py
index 843bb3d7b1..d6b34d5ee2 100644
--- a/helm_tests/other/test_redis.py
+++ b/helm_tests/other/test_redis.py
@@ -143,7 +143,9 @@ class TestRedis:
self.assert_broker_url_env(k8s_obj_by_key)
@pytest.mark.parametrize("executor", CELERY_EXECUTORS_PARAMS)
- def test_redis_by_chart_password_secret_name_missing_broker_url_secret_name(self, executor):
+ def test_redis_by_chart_password_secret_name_missing_broker_url_secret_name_and_broker_url_cmd(
+ self, executor
+ ):
with pytest.raises(CalledProcessError):
render_chart(
RELEASE_NAME_REDIS,
@@ -185,6 +187,30 @@ class TestRedis:
self.assert_broker_url_env(k8s_obj_by_key, expected_broker_url_secret_name)
+ @pytest.mark.parametrize("executor", CELERY_EXECUTORS_PARAMS)
+ def test_redis_by_chart_password_secret_name_without_broker_url_secret(self, executor):
+ k8s_objects = render_chart(
+ RELEASE_NAME_REDIS,
+ {
+ "executor": executor,
+ "redis": {
+ "enabled": True,
+ "passwordSecretName": "test-redis-password-secret-name",
+ },
+ "env": [
+ {"name": "AIRFLOW__CELERY__BROKER_URL_CMD", "value": "test-broker-url"},
+ ],
+ "enableBuiltInSecretEnvVars": {"AIRFLOW__CELERY__BROKER_URL": False},
+ },
+ )
+ k8s_obj_by_key = prepare_k8s_lookup_dict(k8s_objects)
+ created_redis_objects = SET_POSSIBLE_REDIS_OBJECT_KEYS & set(k8s_obj_by_key.keys())
+
+ assert created_redis_objects == SET_POSSIBLE_REDIS_OBJECT_KEYS - {
+ REDIS_OBJECTS["SECRET_PASSWORD"],
+ REDIS_OBJECTS["NETWORK_POLICY"],
+ }
+
@pytest.mark.parametrize("executor", CELERY_EXECUTORS_PARAMS)
def test_external_redis_broker_url(self, executor):
k8s_objects = render_chart(