Skip to content

Allow airflow jobs check --allow-multiple with --limit 0 - #72677

Merged
henry3260 merged 1 commit into
apache:mainfrom
Eason09053360:fix-jobs-check-allow-multiple-with-limit-zero
Sep 8, 2026
Merged

henry3260 merged 1 commit into
apache:mainfrom
Eason09053360:fix-jobs-check-allow-multiple-with-limit-zero

Conversation

@Eason09053360

Copy link
Copy Markdown
Contributor

airflow jobs check --allow-multiple --limit 0 always exits 1, even though 0 is the documented
value for disabling the limit.

The guard rejected any limit at or below 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.")

Rejecting 1 is correct — asking to see multiple jobs while only inspecting the single most recent
one is contradictory. But 0 means "no upper bound", which is the opposite of contradictory, and it
got caught by the same <=.

Everything else in the codebase already treats 0 as valid:

Where What it says about --limit 0
cli_config.py — ARG_JOB_LIMIT type=positive_int(allow_zero=True), so argparse accepts 0
the flag's own help "The number of recent jobs that will be checked. To disable limit, set 0."
jobs_command.check(), a few lines below the guard if args.limit > 0: query = query.limit(args.limit) — already skips the LIMIT clause for 0
airflowctl jobs check — the successor this command is @deprecated_for_airflowctl in favour of uses args.limit == 1 and ships a --limit 0 --allow-multiple test asserting success

So the guard was the only place that disagreed, and it made the branch below it unreachable.

Impact

Running highly available schedulers, the natural way to ask "are all my schedulers alive?" is:

$ airflow jobs check --job-type SchedulerJob --allow-multiple --limit 0
To use option --allow-multiple, you must set the limit to a value greater than 1.   [rc=1]

The error message then points away from the value that would have worked, so operators fall back to
a guessed upper bound such as --limit 100 (the form the docs and the command epilog show). That
under-reports once more jobs than the bound are running.

Changes

  • Narrow the guard to args.limit == 1. positive_int(allow_zero=True) already rejects negatives,
    so the remaining values are 0, 1, 2, … and == 1 is exact.
  • Reword the error to mention 0, matching airflowctl jobs check verbatim so both CLIs emit the
    same sentence.
  • Document --limit 0 next to the existing high-availability example in check-health.rst. The
    existing --limit 100 example is left as-is.

Tests

test_should_report_success_for_ha_schedulers_with_limit_disabled mirrors the neighbouring
--limit 100 test with --limit 0. Reverting the one-line guard change and running the whole file
fails that test with the old SystemExit; with the change, all 7 tests in the file pass.

The pre-existing test_should_raise_exception_for_allow_multiple_and_limit_1 still passes — the
contradictory --limit 1 case is still rejected.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

@Eason09053360
Eason09053360 force-pushed the fix-jobs-check-allow-multiple-with-limit-zero branch 2 times, most recently from e1a4eeb to 9e8895d Compare September 8, 2026 12:51
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.
@Eason09053360
Eason09053360 force-pushed the fix-jobs-check-allow-multiple-with-limit-zero branch from 9e8895d to d835385 Compare September 8, 2026 14:46
@henry3260
henry3260 merged commit 9de99f8 into apache:main Sep 8, 2026
73 checks passed
@github-actions github-actions Bot added this to the Airflow 3.3.2 milestone Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.2 based on: backport label targeting v3-3-test
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-3-test PR Link

aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Sep 8, 2026
…pache#72677)

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 9de99f8)

Co-authored-by: Y-C <[email protected]>
Co-authored-by: Eason09053360 <[email protected]>
vatsrahul1001 pushed a commit that referenced this pull request Sep 9, 2026
…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 9de99f8)

Co-authored-by: Y-C <[email protected]>
Co-authored-by: Eason09053360 <[email protected]>
regarmukesh3g pushed a commit to regarmukesh3g/airflow that referenced this pull request Sep 27, 2026
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.

Co-authored-by: Eason09053360 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants