Skip to content

Commit

Permalink
Ensure internal api command get the "ready" prefix on start (#38550)
Browse files Browse the repository at this point in the history
This prefix is used by _get_num_ready_workers_running to determine num workers ready.
  • Loading branch information
dstandish authored Apr 3, 2024
1 parent 26b5bc9 commit b255012
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions airflow/api_internal/gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations

import setproctitle

from airflow import settings


def post_worker_init(_):
"""
Set process title.
This is used by airflow.cli.commands.internal_api_command to track the status of the worker.
"""
old_title = setproctitle.getproctitle()
setproctitle.setproctitle(settings.GUNICORN_WORKER_READY_PREFIX + old_title)
2 changes: 2 additions & 0 deletions airflow/cli/commands/internal_api_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def internal_api(args):
str(access_logfile),
"--error-logfile",
str(error_logfile),
"--config",
"python:airflow.api_internal.gunicorn_config",
]

if args.access_logformat and args.access_logformat.strip():
Expand Down
2 changes: 2 additions & 0 deletions tests/cli/commands/test_internal_api_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def test_cli_internal_api_args(self):
"-",
"--error-logfile",
"-",
"--config",
"python:airflow.api_internal.gunicorn_config",
"--access-logformat",
"custom_log_format",
"airflow.cli.commands.internal_api_command:cached_app()",
Expand Down

0 comments on commit b255012

Please sign in to comment.