-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KPO to tolerate missing xcom config functions on hook #31258
KPO to tolerate missing xcom config functions on hook #31258
Conversation
We probably should not be configuring xcom settings from the hook in this way but for better or worse we've done it, first in apache#26766 and again in apache#28125. The problem is that other operators derived from KPO, e.g. GKEStartPodOperator, may use a different hook that doesn't have this xcom-specific methods. So KPO needs to tolerate that.
if hasattr(self.hook, "get_xcom_sidecar_container_image"): | ||
sidecar_container_image = self.hook.get_xcom_sidecar_container_image() | ||
if hasattr(self.hook, "get_xcom_sidecar_container_resources"): | ||
sidecar_container_resources = self.hook.get_xcom_sidecar_container_resources() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think that it would be better to replace these two
if
statements with oneif isinstance(self.hook, GKEPodHook)
. For the long term, maybe we should consider refactoring the abstraction. - Is it possible to unit test it? If so, it would be nice to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO I believe that self.hook
should always return a subclass of KubernetesHook
in all subclasses of KPO. Fortunately, Python's multiple inheritance capability makes this task quite manageable.
WDYT?
Protocol added here #31298 |
We probably should not be configuring xcom settings from the hook in this way but for better or worse we've done it, first in #26766 and again in #28125.
The problem is that other operators derived from KPO, e.g. GKEStartPodOperator, may use a different hook that doesn't have this xcom-specific methods. So KPO needs to tolerate that.