dirrao commented on code in PR #39141:
URL: https://github.com/apache/airflow/pull/39141#discussion_r1573147650
##########
airflow/www/views.py:
##########
@@ -1533,6 +1533,48 @@ def rendered_k8s(self, *, session: Session =
NEW_SESSION):
title=title,
)
+ @expose("/object/rendered-k8s")
+ @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
+ @provide_session
+ def rendered_k8s_data(self, *, session: Session = NEW_SESSION):
+ """Get rendered k8s yaml."""
+ if not settings.IS_K8S_OR_K8SCELERY_EXECUTOR:
+ return {"error": "Not a k8s or k8s_celery executor"}, 404
+ # This part is only used for k8s executor so providers.cncf.kubernetes
must be installed
+ # with the get_rendered_k8s_spec method
+ from airflow.providers.cncf.kubernetes.template_rendering import
get_rendered_k8s_spec
+
+ dag_id = request.args.get("dag_id")
+ task_id = request.args.get("task_id")
+ if task_id is None:
+ return {"error": "Task id not passed in the request"}, 404
+ run_id = request.args.get("run_id")
+ map_index = request.args.get("map_index", -1, type=int)
+ logger.info("Retrieving rendered k8s data.")
+
+ dag: DAG = get_airflow_app().dag_bag.get_dag(dag_id)
+ task = dag.get_task(task_id)
+ dag_run = dag.get_dagrun(run_id=run_id, session=session)
+ ti = dag_run.get_task_instance(task_id=task.task_id,
map_index=map_index, session=session)
+
+ if not ti:
+ return {"error": f"can't find task instance {task.task_id}"}, 404
+ pod_spec = None
+ if not isinstance(ti, TaskInstance):
+ return {"error": f"{task.task_id} is not a task instance"}, 500
+ try:
+ pod_spec = get_rendered_k8s_spec(ti, session=session)
Review Comment:
Does this regenerate the pod spec or load from DB?
--
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]