Skip to content

Commit

Permalink
Add migration-wait-timeout to the helm chart (#20069)
Browse files Browse the repository at this point in the history
The `airflow db check-migrations` command is missing a migration wait timeout
value in the helm chart resulting in unexpected failures at times.

This PR adds a default timeout to the command

Co-authored-by: Kaxil Naik <[email protected]>
  • Loading branch information
ephraimbuddy and kaxil authored Dec 6, 2021
1 parent f9eab1c commit 12c916c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion airflow/cli/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def _check(value):
("-t", "--migration-wait-timeout"),
help="timeout to wait for db to migrate ",
type=int,
default=0,
default=60,
)

# webserver
Expand Down
1 change: 1 addition & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ Create the name of the cleanup service account to use
- airflow
- db
- check-migrations
- --migration-wait-timeout={{ .Values.images.migrationsWaitTimeout }}
{{- else }}
- python
- -c
Expand Down
4 changes: 2 additions & 2 deletions chart/tests/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def test_should_add_extra_containers(self):

@parameterized.expand(
[
("2.0.0", ["airflow", "db", "check-migrations"]),
("2.1.0", ["airflow", "db", "check-migrations"]),
("2.0.0", ["airflow", "db", "check-migrations", "--migration-wait-timeout=60"]),
("2.1.0", ["airflow", "db", "check-migrations", "--migration-wait-timeout=60"]),
("1.10.2", ["python", "-c"]),
],
)
Expand Down
6 changes: 6 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@
"x-docsSection": "Images",
"default": false
},
"migrationsWaitTimeout": {
"description": "The time (in seconds) to wait for the DB migrations to complete.",
"type": "number",
"x-docsSection": "Images",
"default": 60
},
"pod_template": {
"description": "Configuration of the pod_template image.",
"type": "object",
Expand Down
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ images:
# will use the images from 'defaultAirflowRepository:defaultAirflowTag' values
# to run and wait for DB migrations .
useDefaultImageForMigration: false
# timeout (in seconds) for airflow-migrations to complete
migrationsWaitTimeout: 60
pod_template:
repository: ~
tag: ~
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/commands/test_db_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_cli_resetdb(self, mock_resetdb):
def test_cli_check_migrations(self, mock_wait_for_migrations):
db_command.check_migrations(self.parser.parse_args(['db', 'check-migrations']))

mock_wait_for_migrations.assert_called_once_with(timeout=0)
mock_wait_for_migrations.assert_called_once_with(timeout=60)

@mock.patch("airflow.cli.commands.db_command.db.upgradedb")
def test_cli_upgradedb(self, mock_upgradedb):
Expand Down

0 comments on commit 12c916c

Please sign in to comment.