jscheffl commented on code in PR #45958:
URL: https://github.com/apache/airflow/pull/45958#discussion_r1942325603
##########
providers/edge/src/airflow/providers/edge/plugins/edge_executor_plugin.py:
##########
@@ -115,6 +116,26 @@ def status(self, session: Session = NEW_SESSION):
five_min_ago = datetime.now() - timedelta(minutes=5)
return self.render_template("edge_worker_hosts.html", hosts=hosts,
five_min_ago=five_min_ago)
+ @expose("/status/maintenance/<string:worker_name>/on", methods=["POST"])
+ @has_access_view(AccessView.JOBS)
+ @provide_session
+ @csrf.exempt
+ def worker_to_maintenance(self, worker_name: str, session: Session =
NEW_SESSION):
+ from airflow.providers.edge.models.edge_worker import
request_maintenance
+
+ request_maintenance(worker_name, session)
+ return redirect(url_for("EdgeWorkerHosts.status"))
+
+ @expose("/status/maintenance/<string:worker_name>/off", methods=["POST"])
+ @has_access_view(AccessView.JOBS)
+ @provide_session
+ @csrf.exempt
Review Comment:
I just realized that you used `@csrf.exempt` here. THis makes the endpoint
insecure as a browser of an admin can be redirected here via
Cross-Site-Scripting. Can you please improve this @majorosdonat ?
##########
providers/edge/src/airflow/providers/edge/plugins/edge_executor_plugin.py:
##########
@@ -115,6 +116,26 @@ def status(self, session: Session = NEW_SESSION):
five_min_ago = datetime.now() - timedelta(minutes=5)
return self.render_template("edge_worker_hosts.html", hosts=hosts,
five_min_ago=five_min_ago)
+ @expose("/status/maintenance/<string:worker_name>/on", methods=["POST"])
+ @has_access_view(AccessView.JOBS)
+ @provide_session
+ @csrf.exempt
+ def worker_to_maintenance(self, worker_name: str, session: Session =
NEW_SESSION):
+ from airflow.providers.edge.models.edge_worker import
request_maintenance
+
+ request_maintenance(worker_name, session)
+ return redirect(url_for("EdgeWorkerHosts.status"))
+
+ @expose("/status/maintenance/<string:worker_name>/off", methods=["POST"])
+ @has_access_view(AccessView.JOBS)
+ @provide_session
+ @csrf.exempt
Review Comment:
Sorry, that I found this post review/merge...
--
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]