pierrejeambrun commented on code in PR #51738:
URL: https://github.com/apache/airflow/pull/51738#discussion_r2175452478


##########
airflow-core/src/airflow/models/dag.py:
##########
@@ -236,6 +236,7 @@ def _create_orm_dagrun(
     creating_job_id: int | None,
     backfill_id: NonNegativeInt | None,
     triggered_by: DagRunTriggeredByType,
+    triggering_user: str | None = None,

Review Comment:
   ```suggestion
       triggering_user_name: str | None = None,
   ```
   
   Because here again I expect a User object by reading this.



##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -159,6 +159,10 @@ class DagRun(Base, LoggingMixin):
     triggered_by = Column(
         Enum(DagRunTriggeredByType, native_enum=False, length=50)
     )  # Airflow component that triggered the run.
+    triggering_user = Column(
+        String(512),
+        nullable=True,
+    )  # The user that triggered the DagRun, if applicable

Review Comment:
   Shouldn't this be a Foreign Key to the user table? TO be sure that we do not 
have inconsistencies there?



##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -66,12 +67,18 @@
 def dag_trigger(args) -> None:
     """Create a dag run for the specified dag."""
     api_client = get_current_api_client()
+    try:
+        user = getuser()
+    except AirflowConfigException as e:
+        log.warning("Failed to get user name from os: %s, not setting the 
triggering user", e)
+        user = None
     try:
         message = api_client.trigger_dag(
             dag_id=args.dag_id,
             run_id=args.run_id,
             conf=args.conf,
             logical_date=args.logical_date,
+            triggering_user=user,

Review Comment:
   Just one nit, but this might be `triggering_user_name`, everywhere, because 
`triggering_user` might be the `relationship` that will return an actual `User` 
object.



-- 
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]

Reply via email to