mik-laj commented on a change in pull request #9354:
URL: https://github.com/apache/airflow/pull/9354#discussion_r446086461
##########
File path: airflow/www/views.py
##########
@@ -760,22 +761,33 @@ def log(self, session=None):
execution_date=execution_date, form=form,
root=root, wrapped=conf.getboolean('webserver', 'default_wrap'))
- @expose('/elasticsearch')
+ @expose('/redirect_to_external_log')
@has_dag_access(can_dag_read=True)
@has_access
@action_logging
- def elasticsearch(self):
+ @provide_session
+ def redirect_to_external_log(self, session=None):
dag_id = request.args.get('dag_id')
task_id = request.args.get('task_id')
execution_date = request.args.get('execution_date')
+ dttm = timezone.parse(execution_date)
try_number = request.args.get('try_number', 1)
- elasticsearch_frontend = conf.get('elasticsearch', 'frontend')
- log_id_template = conf.get('elasticsearch', 'log_id_template')
- log_id = log_id_template.format(
- dag_id=dag_id, task_id=task_id,
- execution_date=execution_date, try_number=try_number)
- url = 'https://' + elasticsearch_frontend.format(log_id=quote(log_id))
- return redirect(url)
+
+ ti = session.query(models.TaskInstance).filter(
+ models.TaskInstance.dag_id == dag_id,
+ models.TaskInstance.task_id == task_id,
+ models.TaskInstance.execution_date == dttm).first()
+
Review comment:
Can you handle missing TI here? You should probably redirect the user to
the main page + display flash message.
----------------------------------------------------------------
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]