jscheffl commented on code in PR #55626:
URL: https://github.com/apache/airflow/pull/55626#discussion_r2346729809


##########
providers/edge3/src/airflow/providers/edge3/cli/edge_command.py:
##########
@@ -581,4 +618,10 @@ def remove_worker_queues(args) -> None:
             ARG_QUEUES_MANAGE,
         ),
     ),
+    ActionCommand(
+        name="shutdown-all-workers",
+        help=shutdown_all_workers.__doc__,
+        func=shutdown_all_workers,
+        args=(ARG_YES,),

Review Comment:
   Does it make sense to add also a `--wait` option such that the command only 
returns when all jobs have drained and workers are down? (Do we have the same 
on shutdown as well or maintenance? I don't remember...)



##########
providers/edge3/src/airflow/providers/edge3/cli/edge_command.py:
##########
@@ -351,6 +351,37 @@ def remote_worker_request_shutdown(args) -> None:
     logger.info("Requested shutdown of Edge Worker host %s by %s.", 
args.edge_hostname, getuser())
 
 
+@cli_utils.action_cli(check_db=False)
+@providers_configuration_loaded
+def shutdown_all_workers(args) -> None:
+    """Request graceful shutdown of all edge workers."""
+    _check_valid_db_connection()
+    if not (
+        args.yes
+        or input("This will shutdown all active edge workers, this cannot be 
undone! Proceed? (y/n)").upper()
+        == "Y"
+    ):
+        raise SystemExit("Cancelled")
+
+    from airflow.providers.edge3.models.edge_worker import 
get_registered_edge_hosts, request_shutdown
+
+    all_hosts = list(get_registered_edge_hosts())
+    if not all_hosts:
+        logger.info("No edge workers found to shutdown.")
+        return
+
+    shutdown_count = 0
+    for host in all_hosts:
+        try:
+            request_shutdown(host.worker_name)

Review Comment:
   nit: Shutdown is also requested if the worker is already offline.
   Might make sense only to request when the status is not offline and not 
unknown.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to