Skip to content

Commit

Permalink
Add TODOs in providers code for Subdag code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxil committed Sep 2, 2024
1 parent 7d3a402 commit d20f098
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions airflow/providers/cncf/kubernetes/operators/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ def _get_ti_pod_labels(context: Context | None = None, include_try_number: bool
if include_try_number:
labels.update(try_number=ti.try_number)
# In the case of sub dags this is just useful
# TODO: Remove this when the minimum version of Airflow is bumped to 3.0
if getattr(context["dag"], "parent_dag", False):
labels["parent_dag_id"] = context["dag"].parent_dag.dag_id # type: ignore[attr-defined]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def create_labels_for_pod(context: dict | None = None, include_try_number: bool
labels.update(try_number=ti.try_number)

# In the case of sub dags this is just useful
# TODO: Remove this when the minimum version of Airflow is bumped to 3.0
if getattr(context["dag"], "is_subdag", False):
labels["parent_dag_id"] = context["dag"].parent_dag.dag_id
# Ensure that label is valid for Kube,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ def create_dag_specific_permissions(self) -> None:
dags = dagbag.dags.values()

for dag in dags:
# TODO: Remove this when the minimum version of Airflow is bumped to 3.0
root_dag_id = (getattr(dag, "parent_dag", None) or dag).dag_id
for resource_name, resource_values in self.RESOURCE_DETAILS_MAP.items():
dag_resource_name = self._resource_name(root_dag_id, resource_name)
Expand Down Expand Up @@ -2733,6 +2734,7 @@ def filter_roles_by_perm_with_action(self, action_name: str, role_ids: list[int]
).all()

def _get_root_dag_id(self, dag_id: str) -> str:
# TODO: The "root_dag_id" check can be remove when the minimum version of Airflow is bumped to 3.0
if "." in dag_id and hasattr(DagModel, "root_dag_id"):
dm = self.appbuilder.get_session.execute(
select(DagModel.dag_id, DagModel.root_dag_id).where(DagModel.dag_id == dag_id)
Expand Down

0 comments on commit d20f098

Please sign in to comment.