Skip to content

Commit 0b84f77

Browse files
Only send hostname to celery worker if passed in cli (#55913)
* Only send hostname to celery worker if passed in cli We were setting the hostname in the celery worker, even if the user did not specify one. This meant we were passing on None. Historically, that has still resulted in the default value being used instead of None, but that has changed in click 8.3.0 (which celery uses in its cli). Either way, no need for us to pass it! * Fix test It'll actually run when #55915 is merged, but it will pass when it does start running.
1 parent ebd1f01 commit 0b84f77

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

providers/celery/src/airflow/providers/celery/cli/celery_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ def worker(args):
239239
args.queues,
240240
"--concurrency",
241241
args.concurrency,
242-
"--hostname",
243-
args.celery_hostname,
244242
"--loglevel",
245243
celery_log_level,
246244
]
245+
if args.celery_hostname:
246+
options.extend(["--hostname", args.celery_hostname])
247247
if autoscale:
248248
options.extend(["--autoscale", autoscale])
249249
if args.without_mingle:

providers/celery/tests/unit/celery/cli/test_celery_command.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class TestWorkerStart:
131131
@classmethod
132132
def setup_class(cls):
133133
with conf_vars({("core", "executor"): "CeleryExecutor"}):
134+
importlib.reload(executor_loader)
134135
importlib.reload(cli_parser)
135136
cls.parser = cli_parser.get_parser()
136137

@@ -172,10 +173,10 @@ def test_worker_started_with_required_arguments(self, mock_celery_app, mock_pope
172173
queues,
173174
"--concurrency",
174175
int(concurrency),
175-
"--hostname",
176-
celery_hostname,
177176
"--loglevel",
178177
conf.get("logging", "CELERY_LOGGING_LEVEL"),
178+
"--hostname",
179+
celery_hostname,
179180
"--autoscale",
180181
autoscale,
181182
"--without-mingle",

0 commit comments

Comments
 (0)