This is an automated email from the ASF dual-hosted git repository.
kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new afa1723 Remove TaskInstance.log_filepath attribute (#15217)
afa1723 is described below
commit afa1723d2493fa23676f1b3d34c8b71f41d7503f
Author: Kamil BreguĊa <[email protected]>
AuthorDate: Mon May 24 22:48:44 2021 +0200
Remove TaskInstance.log_filepath attribute (#15217)
* Remove TaskInstance.log_filepath attribute
* fixup! Remove TaskInstance.log_filepath attribute
* Update UPDATING.md
Co-authored-by: Kaxil Naik <[email protected]>
Co-authored-by: Kaxil Naik <[email protected]>
---
UPDATING.md | 10 ++++++++++
airflow/models/taskinstance.py | 9 ---------
docs/apache-airflow/howto/email-config.rst | 1 -
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/UPDATING.md b/UPDATING.md
index 2bf424c..bf98557 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -72,6 +72,16 @@ https://developers.google.com/style/inclusive-documentation
-->
+### Remove `TaskInstance.log_filepath` attribute
+
+This method returned incorrect values for a long time, because it did not take
into account the different
+logger configuration and task retries. We have also started supporting more
advanced tools that don't use
+files, so it is impossible to determine the correct file path in every case
e.g. Stackdriver doesn't use files
+but identifies logs based on labels. For this reason, we decided to delete
this attribute.
+
+If you need to read logs, you can use
`airflow.utils.log.log_reader.TaskLogReader` class, which does not have
+the above restrictions.
+
### Default Task Pools Slots can be set using ``[core]
default_pool_task_slot_count``
By default tasks are running in `default_pool`. `default_pool` is initialized
with `128` slots and user can change the
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index e5ff20b..426b942 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -514,13 +514,6 @@ class TaskInstance(Base, LoggingMixin): # pylint:
disable=R0902,R0904
return cmd
@property
- def log_filepath(self):
- """Filepath for TaskInstance"""
- iso = self.execution_date.isoformat()
- the_log = os.path.expanduser(conf.get('logging', 'BASE_LOG_FOLDER'))
- return f"{the_log}/{self.dag_id}/{self.task_id}/{iso}.log"
-
- @property
def log_url(self):
"""Log URL for TaskInstance"""
iso = quote(self.execution_date.isoformat())
@@ -1812,7 +1805,6 @@ class TaskInstance(Base, LoggingMixin): # pylint:
disable=R0902,R0904
'Exception:<br>{{exception_html}}<br>'
'Log: <a href="{{ti.log_url}}">Link</a><br>'
'Host: {{ti.hostname}}<br>'
- 'Log file: {{ti.log_filepath}}<br>'
'Mark success: <a href="{{ti.mark_success_url}}">Link</a><br>'
)
@@ -1821,7 +1813,6 @@ class TaskInstance(Base, LoggingMixin): # pylint:
disable=R0902,R0904
'Exception:<br>Failed attempt to attach error logs<br>'
'Log: <a href="{{ti.log_url}}">Link</a><br>'
'Host: {{ti.hostname}}<br>'
- 'Log file: {{ti.log_filepath}}<br>'
'Mark success: <a href="{{ti.mark_success_url}}">Link</a><br>'
)
diff --git a/docs/apache-airflow/howto/email-config.rst
b/docs/apache-airflow/howto/email-config.rst
index 98372f5..2aa9912 100644
--- a/docs/apache-airflow/howto/email-config.rst
+++ b/docs/apache-airflow/howto/email-config.rst
@@ -50,7 +50,6 @@ For example a ``html_content_template`` file could look like
this:
Exception:<br>{{exception_html}}<br>
Log: <a href="{{ti.log_url}}">Link</a><br>
Host: {{ti.hostname}}<br>
- Log file: {{ti.log_filepath}}<br>
Mark success: <a href="{{ti.mark_success_url}}">Link</a><br>
.. note::