Skip to content

Commit

Permalink
Deprecated database configuration removed (#42126)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirrao authored Sep 17, 2024
1 parent 8fe2861 commit 7dea23f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
15 changes: 1 addition & 14 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,7 @@ def sensitive_config_values(self) -> Set[tuple[str, str]]: # noqa: UP006
# A mapping of (new section, new option) -> (old section, old option, since_version).
# When reading new option, the old option will be checked to see if it exists. If it does a
# DeprecationWarning will be issued and the old option will be used instead
deprecated_options: dict[tuple[str, str], tuple[str, str, str]] = {
("database", "sql_alchemy_conn"): ("core", "sql_alchemy_conn", "2.3.0"),
("database", "sql_engine_encoding"): ("core", "sql_engine_encoding", "2.3.0"),
("database", "sql_engine_collation_for_ids"): ("core", "sql_engine_collation_for_ids", "2.3.0"),
("database", "sql_alchemy_pool_enabled"): ("core", "sql_alchemy_pool_enabled", "2.3.0"),
("database", "sql_alchemy_pool_size"): ("core", "sql_alchemy_pool_size", "2.3.0"),
("database", "sql_alchemy_max_overflow"): ("core", "sql_alchemy_max_overflow", "2.3.0"),
("database", "sql_alchemy_pool_recycle"): ("core", "sql_alchemy_pool_recycle", "2.3.0"),
("database", "sql_alchemy_pool_pre_ping"): ("core", "sql_alchemy_pool_pre_ping", "2.3.0"),
("database", "sql_alchemy_schema"): ("core", "sql_alchemy_schema", "2.3.0"),
("database", "sql_alchemy_connect_args"): ("core", "sql_alchemy_connect_args", "2.3.0"),
("database", "load_default_connections"): ("core", "load_default_connections", "2.3.0"),
("database", "max_db_retries"): ("core", "max_db_retries", "2.3.0"),
}
deprecated_options: dict[tuple[str, str], tuple[str, str, str]] = {}

# A mapping of new section -> (old section, since_version).
deprecated_sections: dict[str, tuple[str, str]] = {}
Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ What does "MySQL Server has gone away" mean?

You may occasionally experience ``OperationalError`` with the message "MySQL Server has gone away". This is due to the
connection pool keeping connections open too long and you are given an old connection that has expired. To ensure a
valid connection, you can set :ref:`config:core__sql_alchemy_pool_recycle` to ensure connections are invalidated after
valid connection, you can set :ref:`config:database__sql_alchemy_pool_recycle` to ensure connections are invalidated after
that many seconds and new ones are created.


Expand Down
14 changes: 14 additions & 0 deletions newsfragments/42126.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Removed deprecated database configuration.

* Removed deprecated configuration ``sql_alchemy_conn`` from ``core``. Please use ``sql_alchemy_conn`` from ``database`` instead.
* Removed deprecated configuration ``sql_engine_encoding`` from ``core``. Please use ``sql_engine_encoding`` from ``database`` instead.
* Removed deprecated configuration ``sql_engine_collation_for_ids`` from ``core``. Please use ``sql_engine_collation_for_ids`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_pool_enabled`` from ``core``. Please use ``sql_alchemy_pool_enabled`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_pool_size`` from ``core``. Please use ``sql_alchemy_pool_size`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_max_overflow`` from ``core``. Please use ``sql_alchemy_max_overflow`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_pool_recycle`` from ``core``. Please use ``sql_alchemy_pool_recycle`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_pool_pre_ping`` from ``core``. Please use ``sql_alchemy_pool_pre_ping`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_schema`` from ``core``. Please use ``sql_alchemy_schema`` from ``database`` instead.
* Removed deprecated configuration ``sql_alchemy_connect_args`` from ``core``. Please use ``sql_alchemy_connect_args`` from ``database`` instead.
* Removed deprecated configuration ``load_default_connections`` from ``core``. Please use ``load_default_connections`` from ``database`` instead.
* Removed deprecated configuration ``max_db_retries`` from ``core``. Please use ``max_db_retries`` from ``database`` instead.
13 changes: 8 additions & 5 deletions tests/api_connexion/endpoints/test_config_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@
}

MOCK_CONF_WITH_SENSITIVE_VALUE = {
"core": {"parallelism": "1024", "sql_alchemy_conn": "mock_conn"},
"core": {"parallelism": "1024"},
"smtp": {
"smtp_host": "localhost",
"smtp_mail_from": "[email protected]",
},
"database": {
"sql_alchemy_conn": "mock_conn",
},
}


Expand Down Expand Up @@ -263,10 +266,10 @@ def test_should_respond_200_text_plain(self, mock_as_dict):
@pytest.mark.parametrize(
"section, option",
[
("core", "sql_alchemy_conn"),
("core", "SQL_ALCHEMY_CONN"),
("corE", "sql_alchemy_conn"),
("CORE", "sql_alchemy_conn"),
("database", "sql_alchemy_conn"),
("database", "SQL_ALCHEMY_CONN"),
("databasE", "sql_alchemy_conn"),
("DATABASE", "sql_alchemy_conn"),
],
)
def test_should_respond_200_text_plain_with_non_sensitive_only(self, mock_as_dict, section, option):
Expand Down
4 changes: 3 additions & 1 deletion tests/core/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@

HOME_DIR = os.path.expanduser("~")

# The conf has been updated with deactivate_stale_dags_interval to test the functionality of deprecated options support.
# The conf has been updated with sql_alchemy_con and deactivate_stale_dags_interval to test the
# functionality of deprecated options support.
conf.deprecated_options[("database", "sql_alchemy_conn")] = ("core", "sql_alchemy_conn", "2.3.0")
conf.deprecated_options[("scheduler", "parsing_cleanup_interval")] = (
"scheduler",
"deactivate_stale_dags_interval",
Expand Down

0 comments on commit 7dea23f

Please sign in to comment.