alexInhert opened a new issue #18253:
URL: https://github.com/apache/airflow/issues/18253


   ### Description
   
   Airflow offers Task policies.
   The problem is that while task policy alter the task and replace parameters 
there is no way to indicate to the user that parameters were switched.
   
   
   ### Use case/motivation
   
   Consider the following:
   ```
   def task_policy(task: BaseOperator):
       if task.timeout > timedelta(hours=10):
           task.timeout = timedelta(hours=10)
   ```
   
   This replace the timeout for task if criteria met. However the problem is 
that if you set timeout 20 hours in your code this is what you will see in task 
instance details. You won't see 10 you will see 20.
   Also if I do:
   ```
   def task_policy(task: BaseOperator):
       if task.timeout > timedelta(hours=10):
           task.timeout = timedelta(hours=10)
           self.log("task policy changed timeout to 10 hours")
   ```
   
   This log will be printed in the web server log! it will not be printed in 
the task log.
   
   Result: the user who set timeout of 20 hours and the task timouted after 10 
has no idea why it happened. He can't see it in the logs, he can't see it in 
task details. he is completely clueless.
   
   
   Desired solution - allow to write to the task log from the task policy and 
if possible indicate in the task instance that a policy applied on the task and 
changed values.
   
   ### Related issues
   
   no
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to