You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Eason09053360 (via GitHub)" <gi...@apache.org> on 2026/09/14 17:44:21 UTC
[PR] Fix scheduler refusing to start when [scheduler] only_idle is enabled [airflow]
Eason09053360 opened a new pull request, #73141:
URL: https://github.com/apache/airflow/pull/73141
## Why
Enabling the documented `[scheduler] only_idle` option leaves the deployment without a scheduler. `ARG_ONLY_IDLE` resolved its default from config at import time, so the guard in `scheduler_command.scheduler()` could not tell an explicitly typed `--only-idle` from a config-supplied default. Since `[scheduler] num_runs` defaults to `-1`, the guard tripped on every invocation:
```console
$ AIRFLOW__SCHEDULER__ONLY_IDLE=True airflow scheduler
The --only-idle flag requires --num-runs to be set to a positive number. # exit 1
```
The same import-time default made the option impossible to switch off: `action="store_true"` only pushes towards `True`, so once config enabled it, no command line could get back to `False` — the opposite of the usual command-line-beats-config precedence.
The guard itself is only about usability. `SchedulerJobRunner` already ignores `only_idle` when the run limit is not positive (`run_count >= self.num_runs > 0`), so a non-positive `num_runs` is inert rather than dangerous.
## What
`airflow-core/src/airflow/cli/cli_config.py` — `ARG_ONLY_IDLE` becomes tri-state: `default=None` with `argparse.BooleanOptionalAction`, so `None` means "user said nothing", and `--no-only-idle` can override a config-enabled default.
`airflow-core/src/airflow/cli/commands/scheduler_command.py` — `_resolve_only_idle()` reads `[scheduler] only_idle` when the command runs instead of when the parser is built. An explicit `--only-idle` without a positive `--num-runs` still raises `SystemExit` with the same message; the config-supplied case now logs a warning and starts. The warning names both `--num-runs` and `[scheduler] num_runs`, since the non-positive limit can come from either.
`airflow-core/src/airflow/config_templates/config.yml` — record that `only_idle` has no effect unless `num_runs` is positive.
Tests cover the three-way flag, that a config-enabled `only_idle` starts the scheduler and reaches `SchedulerJobRunner`, and that `--no-only-idle` wins over config. `test_only_idle_help_survives_rich_markup_rendering` asserts against rendered `--help` output rather than the raw `help=` kwarg, because the Rich-based help formatter silently swallows `[section]` text — the reason the help string spells the option `scheduler.only_idle`.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 5)
Generated-by: Claude Code (Opus 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix scheduler refusing to start when [scheduler] only_idle is enabled [airflow]
Posted by "Eason09053360 (via GitHub)" <gi...@apache.org>.
Eason09053360 commented on PR #73141:
URL: https://github.com/apache/airflow/pull/73141#issuecomment-5673165857
> LGTM overall, could you please add a newsfragment?
Added — `airflow-core/newsfragments/73141.bugfix.rst` .
Thanks for the review!
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix scheduler refusing to start when [scheduler] only_idle is enabled [airflow]
Posted by "Eason09053360 (via GitHub)" <gi...@apache.org>.
Eason09053360 commented on PR #73141:
URL: https://github.com/apache/airflow/pull/73141#issuecomment-5844211444
cc @shahar1 friendly ping — I’ve added the newsfragment and rebased onto `main`. Would you mind taking another look when you get a chance?
All checks are green. Thanks for reviewing!
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org