ashb opened a new pull request, #23121:
URL: https://github.com/apache/airflow/pull/23121
There are a few ways we can get an exception before ever making it to user
code, and if that happens _also_ warning about "this shouldn't happen" is
obfuscating the original error.
Before:
```
[2022-04-20, 14:48:44 BST] 1103834 QueuedLocalWorker-3
{{airflow.models.taskinstance.TaskInstance taskinstance.py:1865}} WARNING - We
expected to get frame set in local storage but it was not. Please report this
as an issue with full logs at https://github.com/apache/airflow/issues/new
Traceback (most recent call last):
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
1442, in _run_raw_task
self._execute_task_with_callbacks(context, test_mode)
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
1546, in _execute_task_with_callbacks
task_orig = self.render_templates(context=context)
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
2210, in render_templates
rendered_task = self.task.render_template_fields(context)
File "/home/ash/code/airflow/airflow/airflow/models/mappedoperator.py",
line 724, in render_template_fields
unmapped_task = self.unmap(unmap_kwargs=kwargs)
File "/home/ash/code/airflow/airflow/airflow/models/mappedoperator.py",
line 510, in unmap
op = self.operator_class(**unmap_kwargs, _airflow_from_mapped=True)
File "/home/ash/code/airflow/airflow/airflow/models/baseoperator.py", line
390, in apply_defaults
result = func(self, **kwargs, default_args=default_args)
File
"/home/ash/code/airflow/airflow/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py",
line 259, in __init__
self.name = self._set_name(name)
File
"/home/ash/code/airflow/airflow/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py",
line 442, in _set_name
raise AirflowException("`name` is required unless `pod_template_file` or
`full_pod_spec` is set")
airflow.exceptions.AirflowException: `name` is required unless
`pod_template_file` or `full_pod_spec` is set
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
1863, in get_truncated_error_traceback
execution_frame = _TASK_EXECUTION_FRAME_LOCAL_STORAGE.frame
AttributeError: '_thread._local' object has no attribute 'frame'
[2022-04-20, 14:48:44 BST] 1103834 QueuedLocalWorker-3
{{airflow.models.taskinstance.TaskInstance taskinstance.py:1896}} ERROR - Task
failed with exception
Traceback (most recent call last):
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
1442, in _run_raw_task
self._execute_task_with_callbacks(context, test_mode)
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
1546, in _execute_task_with_callbacks
task_orig = self.render_templates(context=context)
File "/home/ash/code/airflow/airflow/airflow/models/taskinstance.py", line
2210, in render_templates
rendered_task = self.task.render_template_fields(context)
File "/home/ash/code/airflow/airflow/airflow/models/mappedoperator.py",
line 724, in render_template_fields
unmapped_task = self.unmap(unmap_kwargs=kwargs)
File "/home/ash/code/airflow/airflow/airflow/models/mappedoperator.py",
line 510, in unmap
op = self.operator_class(**unmap_kwargs, _airflow_from_mapped=True)
File "/home/ash/code/airflow/airflow/airflow/models/baseoperator.py", line
390, in apply_defaults
result = func(self, **kwargs, default_args=default_args)
File
"/home/ash/code/airflow/airflow/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py",
line 259, in __init__
self.name = self._set_name(name)
File
"/home/ash/code/airflow/airflow/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py",
line 442, in _set_name
raise AirflowException("`name` is required unless `pod_template_file` or
`full_pod_spec` is set")
airflow.exceptions.AirflowException: `name` is required unless
`pod_template_file` or `full_pod_spec` is set
```
After we only see the error once, which is much better
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
---
**^ Add meaningful description above**
Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
for more information.
In case of fundamental code change, Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party
License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]