ashb commented on a change in pull request #11815:
URL: https://github.com/apache/airflow/pull/11815#discussion_r517647977
##########
File path: airflow/models/renderedtifields.py
##########
@@ -49,6 +50,7 @@ def __init__(self, ti: TaskInstance, render_templates=True):
self.ti = ti
if render_templates:
ti.render_templates()
+ self.k8s_pod_yaml = ti.render_k8s_pod_yaml()
Review comment:
This is going to cause an exception when the Kube modules aren't
available.
```suggestion
if is_k8s_or_k8scelery_executor():
self.k8s_pod_yaml = ti.render_k8s_pod_yaml()
```
##########
File path: airflow/models/renderedtifields.py
##########
@@ -81,6 +83,31 @@ def get_templated_fields(cls, ti: TaskInstance, session:
Session = None) -> Opti
else:
return None
+ @classmethod
+ @provide_session
+ def get_k8s_pod_yaml(cls, ti: TaskInstance, session: Session = None) ->
Optional[str]:
+ """
+ Get templated field for a TaskInstance from the
RenderedTaskInstanceFields
+ table.
+
+ :param ti: Task Instance
+ :param session: SqlAlchemy Session
+ :return: Rendered Templated TI field
+ """
+ result = (
+ session.query(cls.rendered_fields)
Review comment:
This is going to only select the rendered_fields, not the `k8s_pod_yaml`
field.
```suggestion
session.query(cls.k8s_pod_yaml)
```
You probably need to improve on the tests to cover this as this wasn't
caught.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]