You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vincbeck (via GitHub)" <gi...@apache.org> on 2025/07/30 20:46:51 UTC
[PR] Create multi-team related tables. Create team association with `Variable`, `Connection` and `Pool` [airflow]
vincbeck opened a new pull request, #53946:
URL: https://github.com/apache/airflow/pull/53946
Create tables to define teams and their associations with dag bundles:
- `team`. Contains the list of teams
- `dag_bundle_team`. Define the association between Dag bundle and team. For now we limit one team to be associated with one Dag bundle but we might want to expand it later (multiple teams associated to one Dag bundle). That's why I create a separate table to associate dag bundles and teams. See comment thread in [Changes in the metadata database](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=294816378#AIP67MultiteamdeploymentofAirflowcomponents-Changesinthemetadatadatabase) section in AIP-67.
I also update 3 tables to add nullable field `team_id` to define optional association between a team and the resource:
- `connection`
- `variable`
- `splot_pool`
As a reminder: [AIP-67](https://cwiki.apache.org/confluence/display/AIRFLOW/AIP-67+Multi-team+deployment+of+Airflow+components)
<!--
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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #53946:
URL: https://github.com/apache/airflow/pull/53946#discussion_r2245891200
##########
airflow-core/src/airflow/migrations/versions/0080_3_1_0_add_teams.py:
##########
@@ -0,0 +1,101 @@
+#
+# 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.
+
+"""
+Add tables to store teams and associations with dag bundles.
+
+Update also `connection`, `variable` and `pool` tables to add `team_id` as column.
+
+Revision ID: a3c7f2b18d4e
+Revises: f56f68b9e02f
+Create Date: 2025-07-30 15:46:40.122517
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "a3c7f2b18d4e"
+down_revision = "f56f68b9e02f"
+branch_labels = None
+depends_on = None
+airflow_version = "3.1.0"
+
+
+def upgrade():
+ """Create team table."""
+ op.create_table(
+ "team",
Review Comment:
I think I prefer a uuid. I know multi-team won't be the **most** security hardened product (yet). But I think where it's easy to make small decisions in that direction for future us, we should!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AIP-67 - Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #53946:
URL: https://github.com/apache/airflow/pull/53946
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53946:
URL: https://github.com/apache/airflow/pull/53946#discussion_r2249014099
##########
airflow-core/src/airflow/models/team.py:
##########
@@ -0,0 +1,52 @@
+#
+# 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
+
+from sqlalchemy import Column, ForeignKey, Index, String, Table
+from sqlalchemy.orm import relationship
+from sqlalchemy_utils import UUIDType
+
+from airflow.models.base import Base
+
+dag_bundle_team_association_table = Table(
+ "dag_bundle_team",
+ Base.metadata,
+ Column("dag_bundle_name", ForeignKey("dag_bundle.name", ondelete="CASCADE"), primary_key=True),
+ Column("team_id", ForeignKey("team.id", ondelete="CASCADE"), primary_key=True),
+ Index("idx_dag_bundle_team_dag_bundle_name", "dag_bundle_name", unique=True),
+ Index("idx_dag_bundle_team_team_id", "team_id"),
+)
Review Comment:
I'm not certain about this part, but the rest LGTM. If it works, I'm good with it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AIP-67 - Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53946:
URL: https://github.com/apache/airflow/pull/53946#issuecomment-3218395137
And some conflicts to solve :(
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #53946:
URL: https://github.com/apache/airflow/pull/53946#discussion_r2246166347
##########
airflow-core/src/airflow/migrations/versions/0080_3_1_0_add_teams.py:
##########
@@ -0,0 +1,101 @@
+#
+# 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.
+
+"""
+Add tables to store teams and associations with dag bundles.
+
+Update also `connection`, `variable` and `pool` tables to add `team_id` as column.
+
+Revision ID: a3c7f2b18d4e
+Revises: f56f68b9e02f
+Create Date: 2025-07-30 15:46:40.122517
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "a3c7f2b18d4e"
+down_revision = "f56f68b9e02f"
+branch_labels = None
+depends_on = None
+airflow_version = "3.1.0"
+
+
+def upgrade():
+ """Create team table."""
+ op.create_table(
+ "team",
Review Comment:
I updated the PR to use UUID :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on PR #53946:
URL: https://github.com/apache/airflow/pull/53946#issuecomment-3182011342
Hey @potiuk what do you make of this one, look good to you?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #53946:
URL: https://github.com/apache/airflow/pull/53946#discussion_r2245612271
##########
airflow-core/src/airflow/migrations/versions/0080_3_1_0_add_teams.py:
##########
@@ -0,0 +1,101 @@
+#
+# 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.
+
+"""
+Add tables to store teams and associations with dag bundles.
+
+Update also `connection`, `variable` and `pool` tables to add `team_id` as column.
+
+Revision ID: a3c7f2b18d4e
+Revises: f56f68b9e02f
+Create Date: 2025-07-30 15:46:40.122517
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "a3c7f2b18d4e"
+down_revision = "f56f68b9e02f"
+branch_labels = None
+depends_on = None
+airflow_version = "3.1.0"
+
+
+def upgrade():
+ """Create team table."""
+ op.create_table(
+ "team",
Review Comment:
I hesitated between the 2. I do not think it matters that teams ids are predictable. I tend to use uuid when I know the number of records can be high, which should not be the case here. But I am not strongly opinionated, if you (and/or others?) prefer a uuid, we can use a uuid
##########
airflow-core/src/airflow/models/team.py:
##########
@@ -0,0 +1,51 @@
+#
+# 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
+
+from sqlalchemy import Column, ForeignKey, Index, Integer, String, Table
+from sqlalchemy.orm import relationship
+
+from airflow.models.base import Base
+
+dag_bundle_team_association_table = Table(
+ "dag_bundle_team",
+ Base.metadata,
+ Column("dag_bundle_name", ForeignKey("dag_bundle.name", ondelete="CASCADE"), primary_key=True),
+ Column("team_id", ForeignKey("team.id", ondelete="CASCADE"), primary_key=True),
+ Index("idx_dag_bundle_team_dag_bundle_name", "dag_bundle_name", unique=True),
+ Index("idx_dag_bundle_team_team_id", "team_id"),
+)
+
+
+class Team(Base):
+ """
+ Contains the list of teams defined in the environment.
+
+ This table is only used when Airflow is run in multi-team mode.
+ """
+
+ __tablename__ = "team"
+
+ id = Column(Integer, primary_key=True)
+ name = Column(String(250), unique=True)
+ dag_bundles = relationship(
+ "DagBundleModel", secondary=dag_bundle_team_association_table, back_populates="teams"
+ )
+
+ def __repr__(self):
+ return f"Team {self.id}"
Review Comment:
Makes sense
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Create multi-team related tables. Create team association in `Variable`, `Connection` and `Pool` tables [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #53946:
URL: https://github.com/apache/airflow/pull/53946#discussion_r2243941787
##########
airflow-core/src/airflow/models/team.py:
##########
@@ -0,0 +1,51 @@
+#
+# 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
+
+from sqlalchemy import Column, ForeignKey, Index, Integer, String, Table
+from sqlalchemy.orm import relationship
+
+from airflow.models.base import Base
+
+dag_bundle_team_association_table = Table(
+ "dag_bundle_team",
+ Base.metadata,
+ Column("dag_bundle_name", ForeignKey("dag_bundle.name", ondelete="CASCADE"), primary_key=True),
+ Column("team_id", ForeignKey("team.id", ondelete="CASCADE"), primary_key=True),
+ Index("idx_dag_bundle_team_dag_bundle_name", "dag_bundle_name", unique=True),
+ Index("idx_dag_bundle_team_team_id", "team_id"),
+)
+
+
+class Team(Base):
+ """
+ Contains the list of teams defined in the environment.
+
+ This table is only used when Airflow is run in multi-team mode.
+ """
+
+ __tablename__ = "team"
+
+ id = Column(Integer, primary_key=True)
+ name = Column(String(250), unique=True)
+ dag_bundles = relationship(
+ "DagBundleModel", secondary=dag_bundle_team_association_table, back_populates="teams"
+ )
+
+ def __repr__(self):
+ return f"Team {self.id}"
Review Comment:
Include the name in the repr too?
##########
airflow-core/src/airflow/migrations/versions/0080_3_1_0_add_teams.py:
##########
@@ -0,0 +1,101 @@
+#
+# 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.
+
+"""
+Add tables to store teams and associations with dag bundles.
+
+Update also `connection`, `variable` and `pool` tables to add `team_id` as column.
+
+Revision ID: a3c7f2b18d4e
+Revises: f56f68b9e02f
+Create Date: 2025-07-30 15:46:40.122517
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "a3c7f2b18d4e"
+down_revision = "f56f68b9e02f"
+branch_labels = None
+depends_on = None
+airflow_version = "3.1.0"
+
+
+def upgrade():
+ """Create team table."""
+ op.create_table(
+ "team",
Review Comment:
Do we care that this will lead to predictable team ids? I think making this something like a random uuid is my preference.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org