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

Deprecated configuration removed #42129

Merged
merged 7 commits into from
Sep 16, 2024
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
20 changes: 1 addition & 19 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,6 @@ def sensitive_config_values(self) -> Set[tuple[str, str]]: # noqa: UP006
# 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]] = {
("celery", "worker_precheck"): ("core", "worker_precheck", "2.0.0"),
("scheduler", "parsing_processes"): ("scheduler", "max_threads", "1.10.14"),
("operators", "default_queue"): ("celery", "default_queue", "2.1.0"),
("core", "hide_sensitive_var_conn_fields"): ("admin", "hide_sensitive_variable_fields", "2.1.0"),
("core", "sensitive_var_conn_names"): ("admin", "sensitive_variable_fields", "2.1.0"),
("core", "default_pool_task_slot_count"): ("core", "non_pooled_task_slot_count", "1.10.4"),
("core", "max_active_tasks_per_dag"): ("core", "dag_concurrency", "2.2.0"),
("api", "access_control_allow_origins"): ("api", "access_control_allow_origin", "2.2.0"),
("api", "auth_backends"): ("api", "auth_backend", "2.3.0"),
("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"),
Expand All @@ -347,19 +338,10 @@ def sensitive_config_values(self) -> Set[tuple[str, str]]: # noqa: UP006
("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"),
("scheduler", "parsing_cleanup_interval"): ("scheduler", "deactivate_stale_dags_interval", "2.5.0"),
("scheduler", "task_queued_timeout_check_interval"): (
"kubernetes_executor",
"worker_pods_pending_timeout_check_interval",
"2.6.0",
),
("fab", "update_fab_perms"): ("webserver", "update_fab_perms", "2.9.0"),
("fab", "auth_rate_limited"): ("webserver", "auth_rate_limited", "2.9.0"),
("fab", "auth_rate_limit"): ("webserver", "auth_rate_limit", "2.9.0"),
}

# A mapping of new section -> (old section, since_version).
deprecated_sections: dict[str, tuple[str, str]] = {"kubernetes_executor": ("kubernetes", "2.5.0")}
deprecated_sections: dict[str, tuple[str, str]] = {}

# Now build the inverse so we can go from old_section/old_key to new_section/new_key
# if someone tries to retrieve it based on old_section/old_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def __init__(self):
self.last_handled: dict[TaskInstanceKey, float] = {}
self.kubernetes_queue: str | None = None
self.task_publish_retries: Counter[TaskInstanceKey] = Counter()
self.task_publish_max_retries = conf.getint("kubernetes", "task_publish_max_retries", fallback=0)
self.task_publish_max_retries = conf.getint(
"kubernetes_executor", "task_publish_max_retries", fallback=0
)
super().__init__(parallelism=self.kube_config.parallelism)

def _list_pods(self, query_kwargs):
Expand Down
12 changes: 9 additions & 3 deletions airflow/providers/fab/auth_manager/fab_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,15 @@ def _sync_appbuilder_roles(self):
# Otherwise, when the name of a view or menu is changed, the framework
# will add the new Views and Menus names to the backend, but will not
# delete the old ones.
if conf.getboolean(
"fab", "UPDATE_FAB_PERMS", fallback=conf.getboolean("webserver", "UPDATE_FAB_PERMS")
):
from packaging.version import Version

from airflow.version import version

if Version(Version(version).base_version) >= Version("3.0.0"):
fallback = None
else:
fallback = conf.getboolean("webserver", "UPDATE_FAB_PERMS")
if conf.getboolean("fab", "UPDATE_FAB_PERMS", fallback=fallback):
self.security_manager.sync_roles()


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

* Removed deprecated configuration ``worker_precheck`` from ``core``. Please use ``worker_precheck`` from ``celery`` instead.
* Removed deprecated configuration ``max_threads`` from ``scheduler``. Please use ``parsing_processes`` from ``scheduler`` instead.
* Removed deprecated configuration ``default_queue`` from ``celery``. Please use ``default_queue`` from ``operators`` instead.
* Removed deprecated configuration ``hide_sensitive_variable_fields`` from ``admin``. Please use ``hide_sensitive_var_conn_fields`` from ``core`` instead.
* Removed deprecated configuration ``sensitive_variable_fields`` from ``admin``. Please use ``sensitive_var_conn_names`` from ``core`` instead.
* Removed deprecated configuration ``non_pooled_task_slot_count`` from ``core``. Please use ``default_pool_task_slot_count`` from ``core`` instead.
* Removed deprecated configuration ``dag_concurrency`` from ``core``. Please use ``max_active_tasks_per_dag`` from ``core`` instead.
* Removed deprecated configuration ``access_control_allow_origin`` from ``api``. Please use ``access_control_allow_origins`` from ``api`` instead.
* Removed deprecated configuration ``auth_backend`` from ``api``. Please use ``auth_backends`` from ``api`` instead.
* Removed deprecated configuration ``deactivate_stale_dags_interval`` from ``scheduler``. Please use ``parsing_cleanup_interval`` from ``scheduler`` instead.
* Removed deprecated configuration ``worker_pods_pending_timeout_check_interval`` from ``kubernetes_executor``. Please use ``task_queued_timeout_check_interval`` from ``scheduler`` instead.
* Removed deprecated configuration ``update_fab_perms`` from ``webserver``. Please use ``update_fab_perms`` from ``fab`` instead.
* Removed deprecated configuration ``auth_rate_limited`` from ``webserver``. Please use ``auth_rate_limited`` from ``fab`` instead.
* Removed deprecated configuration ``auth_rate_limit`` from ``webserver``. Please use ``auth_rate_limit`` from ``fab`` instead.
* Removed deprecated configuration section ``kubernetes``. Please use ``kubernetes_executor`` instead.
15 changes: 7 additions & 8 deletions tests/core/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@

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

# The conf has been updated with deactivate_stale_dags_interval to test the functionality of deprecated options support.
conf.deprecated_options[("scheduler", "parsing_cleanup_interval")] = (
"scheduler",
"deactivate_stale_dags_interval",
"2.5.0",
)


@pytest.fixture(scope="module", autouse=True)
def restore_env():
Expand Down Expand Up @@ -1002,14 +1009,6 @@ def test_deprecated_values_from_conf(self):
@pytest.mark.parametrize(
"old, new",
[
(
("api", "auth_backend", "airflow.providers.fab.auth_manager.api.auth.backend.basic_auth"),
(
"api",
"auth_backends",
"airflow.providers.fab.auth_manager.api.auth.backend.basic_auth,airflow.api.auth.backend.session",
),
),
(
("core", "sql_alchemy_conn", "postgres+psycopg2://localhost/postgres"),
("database", "sql_alchemy_conn", "postgresql://localhost/postgres"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def test_run_next_exception_requeue(
mock_api_client.sanitize_for_serialization.return_value = {}
mock_kube_client.api_client = mock_api_client
config = {
("kubernetes", "pod_template_file"): template_file,
("kubernetes_executor", "pod_template_file"): template_file,
}
with conf_vars(config):
kubernetes_executor = self.kubernetes_executor
Expand Down Expand Up @@ -513,7 +513,7 @@ def test_run_next_pod_reconciliation_error(
mock_api_client = mock.MagicMock()
mock_api_client.sanitize_for_serialization.return_value = {}
mock_kube_client.api_client = mock_api_client
config = {("kubernetes", "pod_template_file"): template_file}
config = {("kubernetes_executor", "pod_template_file"): template_file}
with conf_vars(config):
kubernetes_executor = self.kubernetes_executor
kubernetes_executor.start()
Expand Down Expand Up @@ -597,7 +597,7 @@ def test_pod_template_file_override_in_executor_config(
mock_kube_client = mock.patch("kubernetes.client.CoreV1Api", autospec=True)
mock_get_kube_client.return_value = mock_kube_client

with conf_vars({("kubernetes", "pod_template_file"): None}):
with conf_vars({("kubernetes_executor", "pod_template_file"): None}):
executor = self.kubernetes_executor
executor.start()
try:
Expand Down Expand Up @@ -1227,8 +1227,8 @@ def test_kube_config_get_namespace_list(
self, raw_multi_namespace_mode, raw_value_namespace_list, expected_value_in_kube_config
):
config = {
("kubernetes", "multi_namespace_mode"): raw_multi_namespace_mode,
("kubernetes", "multi_namespace_mode_namespace_list"): raw_value_namespace_list,
("kubernetes_executor", "multi_namespace_mode"): raw_multi_namespace_mode,
("kubernetes_executor", "multi_namespace_mode_namespace_list"): raw_value_namespace_list,
}
with conf_vars(config):
executor = KubernetesExecutor()
Expand Down Expand Up @@ -1504,7 +1504,7 @@ def test_annotations_for_logging_task_metadata(self):
}
get_logs_task_metadata.cache_clear()
try:
with conf_vars({("kubernetes", "logs_task_metadata"): "True"}):
with conf_vars({("kubernetes_executor", "logs_task_metadata"): "True"}):
expected_annotations = {
"dag_id": "dag",
"run_id": "run_id",
Expand All @@ -1525,7 +1525,7 @@ def test_annotations_for_logging_task_metadata_fallback(self):
}
get_logs_task_metadata.cache_clear()
try:
with conf_vars({("kubernetes", "logs_task_metadata"): "False"}):
with conf_vars({("kubernetes_executor", "logs_task_metadata"): "False"}):
expected_annotations = "<omitted>"
annotations_actual = annotations_for_logging_task_metadata(annotations_test)
assert annotations_actual == expected_annotations
Expand Down
4 changes: 3 additions & 1 deletion tests/providers/cncf/kubernetes/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def test_disable_verify_ssl(self):
assert not configuration.verify_ssl

@mock.patch("kubernetes.config.incluster_config.InClusterConfigLoader")
@conf_vars({("kubernetes", "api_client_retry_configuration"): '{"total": 3, "backoff_factor": 0.5}'})
@conf_vars(
{("kubernetes_executor", "api_client_retry_configuration"): '{"total": 3, "backoff_factor": 0.5}'}
)
def test_api_client_retry_configuration_correct_values(self, mock_in_cluster_loader):
get_kube_client(in_cluster=True)
client_configuration = mock_in_cluster_loader().load_and_set.call_args.args[0]
Expand Down