Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed 'request.referrer' from views.py #21751

Merged
merged 21 commits into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f530d7
Added template_ext = ('.json') to databricks operators #18925
utkarsharma2 Feb 11, 2022
b5a2211
Corrected the template_ext value from 'json' to '.json'
utkarsharma2 Feb 12, 2022
9d83cd6
Merge branch 'apache:main' into main
utkarsharma2 Feb 12, 2022
85b2675
Merge branch 'apache:main' into main
utkarsharma2 Feb 13, 2022
c8dd382
Added retries to LivyHook #19384
Feb 13, 2022
a7b58b8
Static code fixes.
Feb 13, 2022
eb6543f
Renamed _retry_args to retry_args.
Feb 14, 2022
3e86860
Passed _retry_args in run_with_advanced_retry().
Feb 14, 2022
104986e
Merge branch 'apache:main' into main
utkarsharma2 Feb 15, 2022
dae69e1
Merge branch 'apache:main' into main
utkarsharma2 Feb 17, 2022
a9b30ee
Added deprecation warning when using hql param.
utkarsharma2 Feb 19, 2022
e0bfed2
Fixed static checks.
utkarsharma2 Feb 19, 2022
bd3f869
Added @overload signatures and sphink's markers to remove 'hql' from …
utkarsharma2 Feb 21, 2022
9db1cb1
Fixed docstings.
utkarsharma2 Feb 21, 2022
532fce2
Added 'sphinx-autoapi-skip' in docstrings of overloaded fucntions.
utkarsharma2 Feb 21, 2022
f7ea13a
Fixed signature of methods in presto hook and trino hook.
utkarsharma2 Feb 21, 2022
c3ce8a1
Merge branch 'apache:main' into main
utkarsharma2 Feb 21, 2022
0701845
Removed dependency on request.referrer header for redirections.
utkarsharma2 Feb 23, 2022
2712688
Merge branch 'apache:main' into main
utkarsharma2 Feb 23, 2022
45862cd
Merge branch 'main' into Referrer-Policy
utkarsharma2 Feb 23, 2022
9daa9e1
Update airflow/www/views.py
utkarsharma2 Feb 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airflow/www/templates/airflow/dag.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ <h4 class="pull-right" style="user-select: none;-moz-user-select: auto;">
<li><a href="{{ url_for('Airflow.trigger', dag_id=dag.dag_id, origin=url_for(request.endpoint, dag_id=dag.dag_id)) }}">Trigger DAG w/ config</a></li>
</ul>
</div>
<a href="{{ url_for('Airflow.delete', dag_id=dag.dag_id) }}" title="Delete&nbsp;DAG" class="btn btn-default btn-icon-only{{ ' disabled' if not dag.can_delete }}"
<a href="{{ url_for('Airflow.delete', dag_id=dag.dag_id, redirect_url=url_for(request.endpoint, dag_id=dag.dag_id)) }}" title="Delete&nbsp;DAG" class="btn btn-default btn-icon-only{{ ' disabled' if not dag.can_delete }}"
onclick="return confirmDeleteDag(this, '{{ dag.safe_dag_id }}')" aria-label="Delete DAG">
<span class="material-icons text-danger" aria-hidden="true">delete_outline</span>
</a>
Expand Down Expand Up @@ -412,7 +412,7 @@ <h4 class="modal-title" id="dagModalLabel">
</span>
</div>
<hr style="margin-bottom: 8px;">
<a id="btn_dagrun_details" class="btn" data-base-url="{{ url_for('Airflow.dagrun_details') }}">
<a id="btn_dagrun_details" class="btn" data-base-url="{{ url_for('Airflow.dagrun_details', redirect_url=request.base_url) }}">
DAG Run details
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/templates/airflow/dags.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ <h2>{{ page_title }}</h2>
</div>
{% endif %}
{# Use dag_id instead of dag.dag_id, because the DAG might not exist in the webserver's DagBag #}
<a href="{{ url_for('Airflow.delete', dag_id=dag.dag_id) }}" onclick="return confirmDeleteDag(this, '{{ dag.dag_id }}')" title="Delete&nbsp;DAG" aria-label="Delete DAG" class="btn btn-sm btn-default btn-icon-only {{ ' disabled' if not dag.can_delete }}">
<a href="{{ url_for('Airflow.delete', dag_id=dag.dag_id, redirect_url=url_for(request.endpoint)) }}" onclick="return confirmDeleteDag(this, '{{ dag.dag_id }}')" title="Delete&nbsp;DAG" aria-label="Delete DAG" class="btn btn-sm btn-default btn-icon-only {{ ' disabled' if not dag.can_delete }}">
<span class="material-icons text-danger" aria-hidden="true">delete_outline</span>
</a>
</div>
Expand Down
17 changes: 10 additions & 7 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,20 +1752,21 @@ def delete(self):

dag_id = request.values.get('dag_id')
origin = get_safe_url(request.values.get('origin'))
redirect_url = get_safe_url(request.values.get('redirect_url'))

try:
delete_dag.delete_dag(dag_id)
except DagNotFound:
flash(f"DAG with id {dag_id} not found. Cannot delete", 'error')
return redirect(request.referrer)
return redirect(redirect_url)
except AirflowException:
flash(
f"Cannot delete DAG with id {dag_id} because some task instances of the DAG "
"are still running. Please mark the task instances as "
"failed/succeeded before deleting the DAG",
"error",
)
return redirect(request.referrer)
return redirect(redirect_url)

flash(f"Deleting DAG with id {dag_id}. May take a couple minutes to fully disappear.")

Expand Down Expand Up @@ -2159,10 +2160,11 @@ def dagrun_details(self, session=None):
dag_run: Optional[DagRun] = (
session.query(DagRun).filter(DagRun.dag_id == dag_id, DagRun.run_id == run_id).one_or_none()
)
redirect_url = get_safe_url(request.values.get('redirect_url'))

if dag_run is None:
flash(f"No DAG run found for DAG id {dag_id} and run id {run_id}", "error")
return redirect(request.referrer or url_for('Airflow.index'))
return redirect(redirect_url or url_for('Airflow.index'))
else:
try:
duration = dag_run.end_date - dag_run.start_date
Expand Down Expand Up @@ -2238,6 +2240,7 @@ def confirm(self):
task_id = args.get('task_id')
dag_run_id = args.get('dag_run_id')
state = args.get('state')
origin = args.get('origin')

upstream = to_boolean(args.get('upstream'))
downstream = to_boolean(args.get('downstream'))
Expand All @@ -2247,13 +2250,13 @@ def confirm(self):
dag = current_app.dag_bag.get_dag(dag_id)
if not dag:
flash(f'DAG {dag_id} not found', "error")
return redirect(request.referrer or url_for('Airflow.index'))
return redirect(origin or url_for('Airflow.index'))

try:
task = dag.get_task(task_id)
except airflow.exceptions.TaskNotFound:
flash(f"Task {task_id} not found", "error")
return redirect(request.referrer or url_for('Airflow.index'))
return redirect(origin or url_for('Airflow.index'))

task.dag = dag

Expand All @@ -2262,12 +2265,12 @@ def confirm(self):
'failed',
):
flash(f"Invalid state {state}, must be either 'success' or 'failed'", "error")
return redirect(request.referrer or url_for('Airflow.index'))
return redirect(origin or url_for('Airflow.index'))

latest_execution_date = dag.get_latest_execution_date()
if not latest_execution_date:
flash(f"Cannot mark tasks as {state}, seem that dag {dag_id} has never run", "error")
return redirect(request.referrer or url_for('Airflow.index'))
return redirect(origin or url_for('Airflow.index'))

from airflow.api.common.mark_tasks import set_state

Expand Down