ramitkataria commented on code in PR #73295:
URL: https://github.com/apache/airflow/pull/73295#discussion_r4079844527
##########
airflow-core/src/airflow/cli/commands/dag_processor_command.py:
##########
@@ -33,12 +34,32 @@
log = logging.getLogger(__name__)
+def _get_team_name(bundle_names: list[str] | None) -> str | None:
+ """
+ Return the team this Dag processor serves, or None when it serves no
single team.
+
+ A bundle belongs to at most one team, so the processor is team-scoped only
when every
+ bundle it parses belongs to the same team. A processor parsing all
bundles, bundles of
+ several teams, or a team-less bundle alongside a team's own is not
team-scoped.
+ """
+ if not bundle_names:
Review Comment:
Should this also return `None` when `[core] multi_team` is off, like
`DagFileProcessorManager._get_team_names` does?
##########
airflow-core/src/airflow/cli/commands/dag_processor_command.py:
##########
@@ -33,12 +34,32 @@
log = logging.getLogger(__name__)
+def _get_team_name(bundle_names: list[str] | None) -> str | None:
+ """
+ Return the team this Dag processor serves, or None when it serves no
single team.
+
+ A bundle belongs to at most one team, so the processor is team-scoped only
when every
+ bundle it parses belongs to the same team. A processor parsing all
bundles, bundles of
+ several teams, or a team-less bundle alongside a team's own is not
team-scoped.
+ """
+ if not bundle_names:
+ return None
+
+ team_names = DagBundleModel.get_team_names(bundle_names)
Review Comment:
Maybe we should use `_get_configured_bundle_team_names()` from
`dag_processing/bundles/manager.py` here instead, so the team comes from config
instead of the DB? My agent told me:
> At this point `sync_bundles()` hasn't run yet (it happens inside
`DagFileProcessorManager.run()`, after `run_job` has already committed the job
row), so on a fresh deployment, or after a bundle moves to another team in
config, the job would keep a missing or stale team until restart.
`airflow_health.py` already resolves teams that way. It would also make a bare
`airflow dag-processor` return the same team as `--bundle-name a b` when every
configured bundle belongs to one team.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/job.py:
##########
@@ -101,6 +103,12 @@ def get_jobs(
FilterParam[str | None],
Depends(filter_param_factory(Job.executor_class, str | None,
filter_name="executor_class")),
],
+ teams: Annotated[
+ FilterParam[list[str]],
+ Depends(
+ filter_param_factory(Job.team_name, list[str],
FilterOptionEnum.IN, "teams", default_factory=list)
Review Comment:
As far as I can tell, with the `IN` filter, there's no way to select jobs
that have no team. Do you think that would be a problem?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]