Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built-in check-migrations command for Airflow>=2 in helm chart #19676

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ Create the name of the cleanup service account to use
{{- end -}}

{{ define "wait-for-migrations-command" }}
{{/* From Airflow 2.0.0 this can become [airflow, db, check-migrations] */}}
{{- if semverCompare ">=2.0.0" .Values.airflowVersion }}
ashb marked this conversation as resolved.
Show resolved Hide resolved
- airflow
- db
- check-migrations
{{- else }}
- python
- -c
- |
Expand Down Expand Up @@ -581,6 +585,7 @@ Create the name of the cleanup service account to use
ticker += 1
time.sleep(1)
logging.info('Waiting for migrations... %s second(s)', ticker)
{{- end }}
{{- end }}

{{ define "registry_docker_config" -}}
Expand Down
18 changes: 18 additions & 0 deletions chart/tests/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ def test_should_add_extra_containers(self):
"image": "test-registry/test-repo:test-tag",
} == jmespath.search("spec.template.spec.containers[-1]", docs[0])

@parameterized.expand(
[
("2.0.0", ["airflow", "db", "check-migrations"]),
("2.1.0", ["airflow", "db", "check-migrations"]),
("1.10.2", ["python", "-c"]),
],
)
def test_wait_for_migration_airflow_version(self, airflow_version, expected_arg):
docs = render_chart(
values={
"airflowVersion": airflow_version,
},
show_only=["templates/webserver/webserver-deployment.yaml"],
)
# Don't test the full string, just the length of the expect matches
actual = jmespath.search("spec.template.spec.initContainers[0].args", docs[0])
assert expected_arg == actual[: len(expected_arg)]

def test_should_add_extra_init_containers(self):
docs = render_chart(
values={
Expand Down