potiuk commented on a change in pull request #19662:
URL: https://github.com/apache/airflow/pull/19662#discussion_r751782933



##########
File path: airflow/models/baseoperator.py
##########
@@ -1000,7 +1000,7 @@ def post_execute(self, context: Any, result: Any = None):
         if self._post_execute_hook is not None:
             self._post_execute_hook(context, result)
 
-    def on_kill(self) -> None:

Review comment:
       Hmm. I went to sleep but could not - started to think about it and I 
think there is a possibility to implement the "meta-class" behaviour. 
   
   The solution has a nice property thatt it coulld enable us in the future to 
add more such API-breaking changes to providers but keep a compatibility layer 
with earlier airlfow versions, with very little effort.
   
   1) we could introiduce a new package `airflow-proviiders-compat` 
   2) The providers would have the "compat" as dependency
   3) `compat` could add some common classes that can be used in providers (for 
example in this case that could be BaseContextKill class (wiht the meta-class 
behaviour of passing the context from "execute" to "on_kill". That could also 
be set of decorators.
   4) all new operators implemeting on_kill(context) should have both 
BaseOperator and BaseContextKill as parents;
   5) The`BaseContextKill` meta class could do all the monkey-patching for 
airflow < 2.3
   
   Then any operator that wants to use the on_kill(context) could just do this 
(and we can also autoamatically  verify it).
   ```
   class KubernetesPodOpertor(BaseOperator,BaseContextKill):
       def on_kill(context):
             ,,,,,
   ```
   
   This way the new providers (with nice clean-up) could continue to use the 
kill-with-context even for Airflow 2.1. 
   
   This might be too much to handle **just** the "context" addition, but it 
also opens up some interesting possibilities of adding other behaviours to 
operators with "compat" latyer, that could make them work the same for earlier 
versions of Airlfow. Also this is very much in line with similar "compat" 
packages for Python.
   
   Thoughts?




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