mgorsk1 opened a new pull request #16945:
URL: https://github.com/apache/airflow/pull/16945
Minor refactor of `KubernetesPodOperator` enabling easy switch of pod
launcher used inside this class.
**Motivation**
In our project we use custom pod launcher which inherits from standard
`pod_launcher.PodLauncher`. With current structure of the code it's not easy to
use custom pod launcher as `execute` method needs to be rewritten.
To give you better understanding of what we are doing below you can find our
abstract custom pod launcher class:
```
class PodLauncherWithHooks(PodLauncher):
def run_pod_async(self, pod, **kwargs):
self.before_create_hook(pod)
result = super(PodLauncherWithHooks, self).run_pod_async(pod,
**kwargs)
self.after_create_hook(pod, result)
return result
def delete_pod(self, pod):
self.before_delete_hook(pod)
result = super(PodLauncherWithHooks, self).delete_pod(pod)
self.after_delete_hook(pod)
return result
def before_create_hook(self, pod):
pass
def after_create_hook(self, pod, result):
pass
def before_delete_hook(self, pod):
pass
def after_delete_hook(self, pod):
pass
```
--
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]