forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
conf
from Task Context (apache#44820)
This was initially added in response to apache#168. However, we now have `ti.log_url` that is used for that; example usages: https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362 https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28 https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76 So, to simplify what we need to pass from API server to the Task SDK, I want to simplify and remove things that aren't needed. In this case, this is good so we don't pass/expore secrets unnecesarily via `conf`
- Loading branch information
Showing
5 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Removed ``conf`` from the Task template context | ||
|
||
The ``conf`` variable, which provided access to the full Airflow configuration (``airflow.cfg``), has been | ||
removed from the Task (Jinja2) template context for security and simplicity. If you | ||
need specific configuration values in your tasks, retrieve them explicitly in your DAG or task code | ||
using the ``airflow.configuration.conf`` module. | ||
|
||
For users retrieving the webserver URL (e.g., to include log links in task or callbacks), one of the | ||
most common use-case, use the ``ti.log_url`` property available in the ``TaskInstance`` context instead. | ||
|
||
Example: | ||
|
||
.. code-block:: python | ||
PythonOperator( | ||
task_id="my_task", | ||
python_callable=my_task_callable, | ||
on_failure_callback=SmtpNotifier( | ||
from_email="[email protected]", | ||
to="[email protected]", | ||
subject="Task {{ ti.task_id }} failed", | ||
html_content="Task <b>{{ ti.task_id }}</b> failed. Log URL: {{ ti.log_url }}", | ||
), | ||
) | ||
* Types of change | ||
|
||
* [x] DAG changes | ||
* [ ] Config changes | ||
* [ ] API changes | ||
* [ ] CLI changes | ||
* [ ] Behaviour changes | ||
* [ ] Plugin changes | ||
* [ ] Dependency changes | ||
|
||
* Migration rules needed | ||
|
||
* Remove context key ``conf`` |