diff --git a/providers/celery/src/airflow/providers/celery/cli/celery_command.py b/providers/celery/src/airflow/providers/celery/cli/celery_command.py index 64379411767c2..3022e7b474be1 100644 --- a/providers/celery/src/airflow/providers/celery/cli/celery_command.py +++ b/providers/celery/src/airflow/providers/celery/cli/celery_command.py @@ -239,11 +239,11 @@ def worker(args): args.queues, "--concurrency", args.concurrency, - "--hostname", - args.celery_hostname, "--loglevel", celery_log_level, ] + if args.celery_hostname: + options.extend(["--hostname", args.celery_hostname]) if autoscale: options.extend(["--autoscale", autoscale]) if args.without_mingle: diff --git a/providers/celery/tests/unit/celery/cli/test_celery_command.py b/providers/celery/tests/unit/celery/cli/test_celery_command.py index 94e339804e3cc..f7f786733e543 100644 --- a/providers/celery/tests/unit/celery/cli/test_celery_command.py +++ b/providers/celery/tests/unit/celery/cli/test_celery_command.py @@ -131,6 +131,7 @@ class TestWorkerStart: @classmethod def setup_class(cls): with conf_vars({("core", "executor"): "CeleryExecutor"}): + importlib.reload(executor_loader) importlib.reload(cli_parser) cls.parser = cli_parser.get_parser() @@ -172,10 +173,10 @@ def test_worker_started_with_required_arguments(self, mock_celery_app, mock_pope queues, "--concurrency", int(concurrency), - "--hostname", - celery_hostname, "--loglevel", conf.get("logging", "CELERY_LOGGING_LEVEL"), + "--hostname", + celery_hostname, "--autoscale", autoscale, "--without-mingle",