This is an automated email from the ASF dual-hosted git repository.
jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new cfe9cc67928 Add linter check for legacy unlimited parallelism (#48423)
cfe9cc67928 is described below
commit cfe9cc6792880bb44d586fafbb0608eb3bf2076b
Author: Jens Scheffler <[email protected]>
AuthorDate: Thu Mar 27 22:46:27 2025 +0100
Add linter check for legacy unlimited parallelism (#48423)
---
.../src/airflow/cli/commands/config_command.py | 17 ++++++++++++++-
.../tests/unit/cli/commands/test_config_command.py | 25 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/airflow-core/src/airflow/cli/commands/config_command.py
b/airflow-core/src/airflow/cli/commands/config_command.py
index 667ee735b25..00835633045 100644
--- a/airflow-core/src/airflow/cli/commands/config_command.py
+++ b/airflow-core/src/airflow/cli/commands/config_command.py
@@ -20,7 +20,7 @@ from __future__ import annotations
from dataclasses import dataclass
from io import StringIO
-from typing import NamedTuple
+from typing import Any, NamedTuple
import pygments
from pygments.lexers.configs import IniLexer
@@ -88,6 +88,7 @@ class ConfigChange:
:param renamed_to: The new section and option if the configuration is
renamed.
:param was_deprecated: If the config is removed, whether the old config
was deprecated.
:param was_removed: If the config is removed.
+ :param is_invalid_if: If the current config value is invalid in the future.
"""
config: ConfigParameter
@@ -97,6 +98,7 @@ class ConfigChange:
renamed_to: ConfigParameter | None = None
was_deprecated: bool = True
was_removed: bool = True
+ is_invalid_if: Any = None
@property
def message(self) -> str | None:
@@ -126,6 +128,13 @@ class ConfigChange:
f"from `{self.config.section}` section. "
f"{self.suggestion}"
)
+ if self.is_invalid_if is not None:
+ value = conf.get(self.config.section, self.config.option)
+ if value == self.is_invalid_if:
+ return (
+ f"Invalid value `{self.is_invalid_if}` set for
`{self.config.option}` configuration parameter "
+ f"in `{self.config.section}` section. {self.suggestion}"
+ )
return None
@@ -229,6 +238,12 @@ CONFIGS_CHANGES = [
ConfigChange(
config=ConfigParameter("core", "log_processor_filename_template"),
),
+ ConfigChange(
+ config=ConfigParameter("core", "parallelism"),
+ was_removed=False,
+ is_invalid_if="0",
+ suggestion="Please set the `parallelism` configuration parameter to a
value greater than 0.",
+ ),
# api
ConfigChange(
config=ConfigParameter("api", "access_control_allow_origin"),
diff --git a/airflow-core/tests/unit/cli/commands/test_config_command.py
b/airflow-core/tests/unit/cli/commands/test_config_command.py
index 75dd395964e..92f4a1ab731 100644
--- a/airflow-core/tests/unit/cli/commands/test_config_command.py
+++ b/airflow-core/tests/unit/cli/commands/test_config_command.py
@@ -466,3 +466,28 @@ class TestConfigLint:
assert expected_message in normalized_output
assert config_change.suggestion in normalized_output
+
+ def test_lint_detects_invalid_config(self):
+ with mock.patch.dict(os.environ, {"AIRFLOW__CORE__PARALLELISM": "0"}):
+ with contextlib.redirect_stdout(StringIO()) as temp_stdout:
+
config_command.lint_config(cli_parser.get_parser().parse_args(["config",
"lint"]))
+
+ output = temp_stdout.getvalue()
+
+ normalized_output = re.sub(r"\s+", " ", output.strip())
+
+ assert (
+ "Invalid value `0` set for `parallelism` configuration parameter
in `core` section."
+ in normalized_output
+ )
+
+ def test_lint_detects_invalid_config_negative(self):
+ with mock.patch.dict(os.environ, {"AIRFLOW__CORE__PARALLELISM": "42"}):
+ with contextlib.redirect_stdout(StringIO()) as temp_stdout:
+
config_command.lint_config(cli_parser.get_parser().parse_args(["config",
"lint"]))
+
+ output = temp_stdout.getvalue()
+
+ normalized_output = re.sub(r"\s+", " ", output.strip())
+
+ assert "Invalid value" not in normalized_output