diff --git a/airflow-core/src/airflow/config_templates/config.yml b/airflow-core/src/airflow/config_templates/config.yml index c4f10ac9624e9..67ae1b62c6cc8 100644 --- a/airflow-core/src/airflow/config_templates/config.yml +++ b/airflow-core/src/airflow/config_templates/config.yml @@ -509,6 +509,15 @@ core: type: string example: ~ default: ~ + multi_team: + description: | + Whether to run the Airflow environment in multi-team mode. + In this mode, different teams can have scoped access to their own resources while still sharing the + same underlying deployment. + version_added: 3.2.0 + type: boolean + example: ~ + default: "False" database: description: ~ options: diff --git a/airflow-core/src/airflow/dag_processing/bundles/manager.py b/airflow-core/src/airflow/dag_processing/bundles/manager.py index f13ea96207715..e58b36b272ea0 100644 --- a/airflow-core/src/airflow/dag_processing/bundles/manager.py +++ b/airflow-core/src/airflow/dag_processing/bundles/manager.py @@ -193,6 +193,13 @@ def parse_config(self) -> None: _add_example_dag_bundle(bundle_config_list) for bundle_config in bundle_config_list: + if bundle_config.team_name and not conf.getboolean("core", "multi_team"): + raise AirflowConfigException( + "Section `dag_processor` key `dag_bundle_config_list` " + "cannot have a team name when multi-team mode is disabled." + "To enable multi-team, you need to update section `core` key `multi_team` in your config." + ) + class_ = import_string(bundle_config.classpath) self._bundle_config[bundle_config.name] = _InternalBundleConfig( bundle_class=class_, diff --git a/airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py b/airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py index b1e8b4f8b651a..f911027ef7a79 100644 --- a/airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py +++ b/airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py @@ -57,6 +57,20 @@ {"my-bundle"}, id="remove_dags_folder_default_add_bundle", ), + pytest.param( + json.dumps( + [ + { + "name": "my-bundle", + "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", + "kwargs": {"path": "/tmp/hihi", "refresh_interval": 1}, + "team_name": "test", + } + ] + ), + "cannot have a team name when multi-team mode is disabled.", + id="add_bundle_with_team", + ), pytest.param( "[]", set(), diff --git a/airflow-core/tests/unit/dag_processing/test_manager.py b/airflow-core/tests/unit/dag_processing/test_manager.py index 1b023381bf54f..e3ff30ae07062 100644 --- a/airflow-core/tests/unit/dag_processing/test_manager.py +++ b/airflow-core/tests/unit/dag_processing/test_manager.py @@ -1169,6 +1169,7 @@ def test_bundle_names_to_parse(self, bundle_names, expected, configure_dag_bundl bundle_names_being_parsed = {b.name for b in manager._dag_bundles} assert bundle_names_being_parsed == expected + @conf_vars({("core", "multi_team"): "true"}) def test_bundles_with_team(self, session): team1_name = "test_team1" team2_name = "test_team2"