Skip to content

Commit

Permalink
Helm chart should set AIRFLOW_HOME from airflowHome (#34839)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstandish committed Nov 7, 2023
1 parent b67a4f7 commit 71e0e6e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ If release name contains chart name it will be used as a full name.
name: {{ template "fernet_key_secret" . }}
key: fernet-key
{{- end }}
- name: AIRFLOW_HOME
value: {{ .Values.airflowHome }}
# For Airflow <2.3, backward compatibility; moved to [database] in 2.3
{{- if .Values.enableBuiltInSecretEnvVars.AIRFLOW__CORE__SQL_ALCHEMY_CONN }}
- name: AIRFLOW__CORE__SQL_ALCHEMY_CONN
Expand Down
2 changes: 2 additions & 0 deletions helm_tests/airflow_aux/test_airflow_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def test_should_disable_some_variables(self):
)
expected_vars = [
"AIRFLOW__CORE__FERNET_KEY",
"AIRFLOW_HOME",
"AIRFLOW_CONN_AIRFLOW_DB",
"AIRFLOW__CELERY__BROKER_URL",
]
Expand All @@ -355,6 +356,7 @@ def test_have_all_variables(self):
)
expected_vars = [
"AIRFLOW__CORE__FERNET_KEY",
"AIRFLOW_HOME",
"AIRFLOW__CORE__SQL_ALCHEMY_CONN",
"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN",
"AIRFLOW_CONN_AIRFLOW_DB",
Expand Down
42 changes: 42 additions & 0 deletions helm_tests/airflow_core/test_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations

import jmespath

from tests.charts.helm_template_generator import render_chart


def test_should_add_airflow_home():
exp_path = "/not/even/a/real/path"
docs = render_chart(
values={"airflowHome": exp_path},
show_only=["templates/webserver/webserver-deployment.yaml"],
)
assert {"name": "AIRFLOW_HOME", "value": exp_path} in jmespath.search(
"spec.template.spec.containers[0].env", docs[0]
)


def test_should_add_airflow_home_notset():
docs = render_chart(
values={},
show_only=["templates/webserver/webserver-deployment.yaml"],
)
assert {"name": "AIRFLOW_HOME", "value": "/opt/airflow"} in jmespath.search(
"spec.template.spec.containers[0].env", docs[0]
)

0 comments on commit 71e0e6e

Please sign in to comment.