Skip to content

Commit a1ee1c3

Browse files
jschefflshahar1
authored andcommitted
Clean Leftovers of RemovedInAirflow3Warning (apache#47264)
* Clean Leftovers of RemovedInAirflow3Warning * Add newsfragment for deprecations * Revert one cleanup in decorator * Replace further leftovers of airflow.api.auth.backend.session in code * Review feedback
1 parent d364b34 commit a1ee1c3

File tree

23 files changed

+30
-186
lines changed

23 files changed

+30
-186
lines changed

Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ function start_api_server_with_examples(){
10211021
return
10221022
fi
10231023
export AIRFLOW__CORE__LOAD_EXAMPLES=True
1024-
export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
1024+
export AIRFLOW__API__AUTH_BACKENDS=airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
10251025
export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True
10261026
echo
10271027
echo "${COLOR_BLUE}Initializing database${COLOR_RESET}"

airflow/api/auth/backend/session.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

airflow/configuration.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def inversed_deprecated_sections(self):
378378
"api": {
379379
"auth_backends": (
380380
re2.compile(r"^airflow\.api\.auth\.backend\.deny_all$|^$"),
381-
"airflow.api.auth.backend.session",
381+
"airflow.providers.fab.auth_manager.api.auth.backend.session",
382382
"3.0",
383383
),
384384
},
@@ -686,10 +686,7 @@ def _upgrade_auth_backends(self):
686686
This is required by the UI for ajax queries.
687687
"""
688688
old_value = self.get("api", "auth_backends", fallback="")
689-
if (
690-
old_value.find("airflow.api.auth.backend.session") == -1
691-
and old_value.find("airflow.providers.fab.auth_manager.api.auth.backend.session") == -1
692-
):
689+
if "airflow.providers.fab.auth_manager.api.auth.backend.session" not in old_value:
693690
new_value = old_value + ",airflow.providers.fab.auth_manager.api.auth.backend.session"
694691
self._update_env_var(section="api", name="auth_backends", new_value=new_value)
695692
self.upgraded_values[("api", "auth_backends")] = old_value
@@ -700,7 +697,7 @@ def _upgrade_auth_backends(self):
700697
os.environ.pop(old_env_var, None)
701698

702699
warnings.warn(
703-
"The auth_backends setting in [api] has had airflow.api.auth.backend.session added "
700+
"The auth_backends setting in [api] missed airflow.providers.fab.auth_manager.api.auth.backend.session "
704701
"in the running config, which is needed by the UI. Please update your config before "
705702
"Apache Airflow 3.0.",
706703
FutureWarning,

airflow/exceptions.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,6 @@ class PodReconciliationError(AirflowException): # type: ignore[no-redef]
475475
"""Raised when an error is encountered while trying to merge pod configs."""
476476

477477

478-
class RemovedInAirflow3Warning(DeprecationWarning):
479-
"""Issued for usage of deprecated features that will be removed in Airflow3."""
480-
481-
deprecated_since: str | None = None
482-
"Indicates the airflow version that started raising this deprecation warning"
483-
484-
485478
class RemovedInAirflow4Warning(DeprecationWarning):
486479
"""Issued for usage of deprecated features that will be removed in Airflow4."""
487480

airflow/executors/base_executor.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
from typing import TYPE_CHECKING, Any, Optional
2727

2828
import pendulum
29-
from deprecated import deprecated
3029

3130
from airflow.cli.cli_config import DefaultHelpParser
3231
from airflow.configuration import conf
33-
from airflow.exceptions import RemovedInAirflow3Warning
3432
from airflow.executors.executor_loader import ExecutorLoader
3533
from airflow.models import Log
3634
from airflow.stats import Stats
@@ -587,24 +585,6 @@ def terminate(self):
587585
"""Get called when the daemon receives a SIGTERM."""
588586
raise NotImplementedError
589587

590-
@deprecated(
591-
reason="Replaced by function `revoke_task`.",
592-
category=RemovedInAirflow3Warning,
593-
action="ignore",
594-
)
595-
def cleanup_stuck_queued_tasks(self, tis: list[TaskInstance]) -> list[str]:
596-
"""
597-
Handle remnants of tasks that were failed because they were stuck in queued.
598-
599-
Tasks can get stuck in queued. If such a task is detected, it will be marked
600-
as `UP_FOR_RETRY` if the task instance has remaining retries or marked as `FAILED`
601-
if it doesn't.
602-
603-
:param tis: List of Task Instances to clean up
604-
:return: List of readable task instances for a warning message
605-
"""
606-
raise NotImplementedError
607-
608588
def revoke_task(self, *, ti: TaskInstance):
609589
"""
610590
Attempt to remove task from executor.

airflow/jobs/scheduler_job_runner.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
import time
2727
from collections import Counter, defaultdict, deque
2828
from collections.abc import Collection, Iterable, Iterator
29-
from contextlib import ExitStack, suppress
29+
from contextlib import ExitStack
3030
from datetime import date, timedelta
3131
from functools import lru_cache, partial
3232
from itertools import groupby
3333
from typing import TYPE_CHECKING, Any, Callable
3434

35-
from deprecated import deprecated
3635
from sqlalchemy import and_, delete, exists, func, select, text, tuple_, update
3736
from sqlalchemy.exc import OperationalError
3837
from sqlalchemy.orm import joinedload, lazyload, load_only, make_transient, selectinload
@@ -42,7 +41,6 @@
4241
from airflow.callbacks.callback_requests import DagCallbackRequest, TaskCallbackRequest
4342
from airflow.configuration import conf
4443
from airflow.dag_processing.bundles.base import BundleUsageTrackingManager
45-
from airflow.exceptions import RemovedInAirflow3Warning
4644
from airflow.executors import workloads
4745
from airflow.executors.base_executor import BaseExecutor
4846
from airflow.executors.executor_loader import ExecutorLoader
@@ -1727,12 +1725,6 @@ def _handle_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> None:
17271725
)
17281726
session.commit()
17291727
except NotImplementedError:
1730-
# this block only gets entered if the executor has not implemented `revoke_task`.
1731-
# in which case, we try the fallback logic
1732-
# todo: remove the call to _stuck_in_queued_backcompat_logic in airflow 3.0.
1733-
# after 3.0, `cleanup_stuck_queued_tasks` will be removed, so we should
1734-
# just continue immediately.
1735-
self._stuck_in_queued_backcompat_logic(executor, stuck_tis)
17361728
continue
17371729

17381730
def _get_tis_stuck_in_queued(self, session) -> Iterable[TaskInstance]:
@@ -1779,28 +1771,6 @@ def _maybe_requeue_stuck_ti(self, *, ti, session):
17791771
)
17801772
ti.set_state(TaskInstanceState.FAILED, session=session)
17811773

1782-
@deprecated(
1783-
reason="This is backcompat layer for older executor interface. Should be removed in 3.0",
1784-
category=RemovedInAirflow3Warning,
1785-
action="ignore",
1786-
)
1787-
def _stuck_in_queued_backcompat_logic(self, executor, stuck_tis):
1788-
"""
1789-
Try to invoke stuck in queued cleanup for older executor interface.
1790-
1791-
TODO: remove in airflow 3.0
1792-
1793-
Here we handle case where the executor pre-dates the interface change that
1794-
introduced `cleanup_tasks_stuck_in_queued` and deprecated `cleanup_stuck_queued_tasks`.
1795-
1796-
"""
1797-
with suppress(NotImplementedError):
1798-
for ti_repr in executor.cleanup_stuck_queued_tasks(tis=stuck_tis):
1799-
self.log.warning(
1800-
"Task instance %s stuck in queued. Will be set to failed.",
1801-
ti_repr,
1802-
)
1803-
18041774
def _reschedule_stuck_task(self, ti: TaskInstance, session: Session):
18051775
session.execute(
18061776
update(TI)

clients/python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@ that uses the API to run the tests. To do that, you need to:
534534

535535
```ini
536536
[api]
537-
auth_backend = airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
537+
auth_backend = airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
538538
```
539539

540540
You can also set it by env variable:
541-
`export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth`
541+
`export AIRFLOW__API__AUTH_BACKENDS=airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth`
542542

543543
* configure your airflow webserver to load example dags
544544
In the `[core]` section of your `airflow.cfg` set:

clients/python/test_python_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# configured also with the basic_auth as backend additionally to regular session backend needed
5252
# by the UI. In the `[api]` section of your `airflow.cfg` set:
5353
#
54-
# auth_backend = airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
54+
# auth_backend = airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
5555
#
5656
# Make sure that your user/name are configured properly - using the user/password that has admin
5757
# privileges in Airflow

contributing-docs/testing/unit_tests.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Handling warnings
4242
By default, in the new tests selected warnings are prohibited:
4343

4444
* ``airflow.exceptions.AirflowProviderDeprecationWarning``
45-
* ``airflow.exceptions.RemovedInAirflow3Warning``
4645

4746
That mean if one of this warning appear during test run and do not captured the test will failed.
4847

dev/README_RELEASE_PYTHON_CLIENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ and allows you to test the client in a real environment.
477477
variable in `files/airflow-breeze-config/init.sh`:
478478

479479
```shell
480-
export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
480+
export AIRFLOW__API__AUTH_BACKENDS=airflow.providers.fab.auth_manager.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
481481
export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True
482482
```
483483

0 commit comments

Comments
 (0)