Skip to content

Conversation

@jason810496
Copy link
Member

@jason810496 jason810496 commented Jul 4, 2025

related: #52581

Why

When I attempt to remove gunicorn dependency in #52581, I found that we are still using gunicorn for daemonization.

What

  • Replace gunicorn.daemonize with run_command_with_daemon_option, this also align the behavior of --daemon option for scheduler, triggerer ... and api-server
  • Add test for api-server with --daemon as well
    • Rename _CommonCLIGunicornTestClass to _CommonCLIUvicornTestClass, since we are using uvicorn instead of gunicorn for api-server now.
  • Replace [api/access_logfile] config with [api/log_config], detail in Remove gunicorn daemonize for api-server #52860 (comment)

@jason810496 jason810496 force-pushed the refactor/api-server/remove-gunicorn-daemonize branch from 1dfe755 to 7a44f9a Compare July 4, 2025 10:22
@jason810496 jason810496 added the area:API Airflow's REST/HTTP API label Jul 4, 2025
@jason810496 jason810496 marked this pull request as ready for review July 4, 2025 10:22
Copy link
Member Author

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

access_log=access_logfile, # type: ignore[arg-type] this line is a strange part for me.

I add # type: ignore[arg-type] to ingore the mypy warning for now.

@jason810496
Copy link
Member Author

jason810496 commented Jul 5, 2025

Hi @potiuk, may I might need hints for replacing config.

I thought replacing them in config.yaml and add the pair in deprecated_option in configuration will be all right.

Thanks in advance!


Update:

I found the root cause.

My step is correct but I set [api/log_config] config default as None in config.yml and I set default=conf.get("api", "log_config") in cli_config module.
There is not need to set default=conf.get("api", "log_config") or should set fallback=None for the --log-config flag in cli_config, since the it is not mandatory.

@jason810496 jason810496 marked this pull request as draft July 6, 2025 02:29
@jason810496 jason810496 force-pushed the refactor/api-server/remove-gunicorn-daemonize branch from 89b529e to 52151fe Compare July 6, 2025 03:08
@jason810496 jason810496 marked this pull request as ready for review July 6, 2025 04:30
Copy link
Member Author

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @potiuk and @pierrejeambrun for the review!
Just resolved all comments and fixed the CI as well.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. One NIT about updating newsfragment.

@jason810496 jason810496 force-pushed the refactor/api-server/remove-gunicorn-daemonize branch from 52151fe to ef4c730 Compare July 7, 2025 14:02
@potiuk potiuk merged commit ab1ee72 into apache:main Jul 7, 2025
57 checks passed
HsiuChuanHsu pushed a commit to HsiuChuanHsu/airflow that referenced this pull request Jul 10, 2025
* Remove gunicorn daemonize for api-server

* Rename _CommonCLIUvicornTestClass

* Add test for api-server with daemon option

* Fix setproctitle on MacOS

* Replace api/access_logfile with api/log_config

* Fix [api/log_config] cli_config

* Remove logging and unsed option in api_server_command

- the logging before daemonization is not logging the correct PID so
  remove it
- should_setup_logging is default as False

* Fix test_run_command_daemon

* Add significant rst
stephen-bracken pushed a commit to stephen-bracken/airflow that referenced this pull request Jul 15, 2025
* Remove gunicorn daemonize for api-server

* Rename _CommonCLIUvicornTestClass

* Add test for api-server with daemon option

* Fix setproctitle on MacOS

* Replace api/access_logfile with api/log_config

* Fix [api/log_config] cli_config

* Remove logging and unsed option in api_server_command

- the logging before daemonization is not logging the correct PID so
  remove it
- should_setup_logging is default as False

* Fix test_run_command_daemon

* Add significant rst
jason810496 added a commit to jason810496/airflow that referenced this pull request Jul 15, 2025
* Remove gunicorn daemonize for api-server

* Rename _CommonCLIUvicornTestClass

* Add test for api-server with daemon option

* Fix setproctitle on MacOS

* Replace api/access_logfile with api/log_config

* Fix [api/log_config] cli_config

* Remove logging and unsed option in api_server_command

- the logging before daemonization is not logging the correct PID so
  remove it
- should_setup_logging is default as False

* Fix test_run_command_daemon

* Add significant rst

(cherry picked from commit ab1ee72)
jason810496 added a commit to jason810496/airflow that referenced this pull request Jul 18, 2025
* Remove gunicorn daemonize for api-server

* Rename _CommonCLIUvicornTestClass

* Add test for api-server with daemon option

* Fix setproctitle on MacOS

* Replace api/access_logfile with api/log_config

* Fix [api/log_config] cli_config

* Remove logging and unsed option in api_server_command

- the logging before daemonization is not logging the correct PID so
  remove it
- should_setup_logging is default as False

* Fix test_run_command_daemon

* Add significant rst

(cherry picked from commit ab1ee72)
potiuk pushed a commit that referenced this pull request Jul 20, 2025
* [v3-0-test] Remove gunicorn daemonize for api-server (#52860)

* Remove gunicorn daemonize for api-server

* Rename _CommonCLIUvicornTestClass

* Add test for api-server with daemon option

* Fix setproctitle on MacOS

* Replace api/access_logfile with api/log_config

* Fix [api/log_config] cli_config

* Remove logging and unsed option in api_server_command

- the logging before daemonization is not logging the correct PID so
  remove it
- should_setup_logging is default as False

* Fix test_run_command_daemon

* Add significant rst

(cherry picked from commit ab1ee72)

* Fix spelling wordlist

* Fix configuration
("api", "require_confirmation_dag_change"): ("webserver", "require_confirmation_dag_change", "3.1.0"),
("api", "instance_name"): ("webserver", "instance_name", "3.1.0"),
("dag_processor", "parsing_pre_import_modules"): ("scheduler", "parsing_pre_import_modules", "3.1.0"),
("api", "log_config"): ("api", "access_logfile", "3.1.0"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not safe to do - they are different config options. As mentioned in the comment above, this will use the old access_logfile value for log_config if it's set, which isn't what we want.

Replace API server ``access_logfile`` configuration with ``log_config``

The API server configuration option ``[api] access_logfile`` has been replaced with ``[api] log_config`` to align with uvicorn's logging configuration instead of the legacy gunicorn approach.
The new ``log_config`` option accepts a path to a logging configuration file compatible with ``logging.config.fileConfig``, providing more flexible logging configuration for the API server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can continue to support a simple access logfile config? I just worry a bit about backcompat, right now this is a breaking change. Maybe we leave access_logfile, build our own log_config file dynamically, and make log_config and access_logfile mutually exclusive? And we should emit a deprecation warning when access_logfile is used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, good and bad news. Good news is no backcompat issues to worry about! I believe it got broken in #45103. Bad news is I don't think access_log ever worked in AF3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants