This is an automated email from the ASF dual-hosted git repository.
vatsrahul1001 pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new de7a4057d89 [v3-3-test] Allow airflow jobs check --allow-multiple with
--limit 0 (#72677) (#72744)
de7a4057d89 is described below
commit de7a4057d8901bd67d840d81a6aad34605dc86b1
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Sep 9 23:01:26 2026 +0530
[v3-3-test] Allow airflow jobs check --allow-multiple with --limit 0
(#72677) (#72744)
The guard rejected every limit at or below 1, but 0 is the documented value
for disabling the limit: argparse accepts it, the flag's own help says "To
disable limit, set 0", and the query builder already honours it. Operators
running highly available schedulers were left guessing a magic upper bound
instead of asking for every alive job, and the error message pointed them
away from the value that would have worked.
The successor command this one is deprecated in favour of, airflowctl jobs
check, has accepted the combination since it was added, so the two CLIs
disagreed about the same flag.
(cherry picked from commit 9de99f8d29cecac48115ff7df6a02bc406bac431)
Co-authored-by: Y-C <[email protected]>
Co-authored-by: Eason09053360
<[email protected]>
---
.../logging-monitoring/check-health.rst | 4 ++++
airflow-core/src/airflow/cli/commands/jobs_command.py | 7 +++++--
.../tests/unit/cli/commands/test_jobs_command.py | 17 +++++++++++++++++
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git
a/airflow-core/docs/administration-and-deployment/logging-monitoring/check-health.rst
b/airflow-core/docs/administration-and-deployment/logging-monitoring/check-health.rst
index c9b1966714a..301516fe6fb 100644
---
a/airflow-core/docs/administration-and-deployment/logging-monitoring/check-health.rst
+++
b/airflow-core/docs/administration-and-deployment/logging-monitoring/check-health.rst
@@ -127,6 +127,10 @@ To check if any scheduler is running when you are using
high availability, run:
airflow jobs check --job-type SchedulerJob --allow-multiple --limit 100
+``--limit`` caps how many jobs are inspected, starting with the ones that
reported a heartbeat most
+recently. Set it to ``0`` to inspect all of them, so that no scheduler is
missed regardless of how
+many are running.
+
CLI Check for Database
----------------------
diff --git a/airflow-core/src/airflow/cli/commands/jobs_command.py
b/airflow-core/src/airflow/cli/commands/jobs_command.py
index 194d8720db2..a8b6f9c7582 100644
--- a/airflow-core/src/airflow/cli/commands/jobs_command.py
+++ b/airflow-core/src/airflow/cli/commands/jobs_command.py
@@ -33,8 +33,11 @@ if TYPE_CHECKING:
@provide_session
def check(args, *, session: Session = NEW_SESSION) -> None:
"""Check if job(s) are still alive."""
- if args.allow_multiple and args.limit <= 1:
- raise SystemExit("To use option --allow-multiple, you must set the
limit to a value greater than 1.")
+ if args.allow_multiple and args.limit == 1:
+ raise SystemExit(
+ "To use option --allow-multiple, you must set the limit to a value
greater than 1 "
+ "or 0 to disable it."
+ )
if args.hostname and args.local:
raise SystemExit("You can't use --hostname and --local at the same
time")
diff --git a/airflow-core/tests/unit/cli/commands/test_jobs_command.py
b/airflow-core/tests/unit/cli/commands/test_jobs_command.py
index 9d17bde437c..6fa1007ef17 100644
--- a/airflow-core/tests/unit/cli/commands/test_jobs_command.py
+++ b/airflow-core/tests/unit/cli/commands/test_jobs_command.py
@@ -94,6 +94,23 @@ class TestCliConfigList:
)
assert "Found 3 alive jobs." in temp_stdout.getvalue()
+ def test_should_report_success_for_ha_schedulers_with_limit_disabled(self,
stdout_capture):
+ with create_session() as session:
+ for _ in range(3):
+ scheduler_job = Job()
+ job_runner = SchedulerJobRunner(job=scheduler_job)
+ scheduler_job.state = State.RUNNING
+ session.add(scheduler_job)
+ session.commit()
+
scheduler_job.heartbeat(heartbeat_callback=job_runner.heartbeat_callback)
+ with stdout_capture as temp_stdout:
+ jobs_command.check(
+ self.parser.parse_args(
+ ["jobs", "check", "--job-type", "SchedulerJob", "--limit",
"0", "--allow-multiple"]
+ )
+ )
+ assert "Found 3 alive jobs." in temp_stdout.getvalue()
+
def test_should_ignore_not_running_jobs(self):
scheduler_jobs = []
job_runners = []