Skip to content
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

Conversation

dstandish
Copy link
Contributor

@dstandish dstandish commented May 12, 2023

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.

dstandish added 2 commits May 12, 2023 10:23
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.
@dstandish dstandish requested a review from jedcunningham as a code owner May 12, 2023 17:34
@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes provider related issues area:providers labels May 12, 2023
@dstandish dstandish changed the title Kpo tolerate missing xcom functions on hook KPO to tolerate missing xcom functions on hook May 12, 2023
@dstandish dstandish changed the title KPO to tolerate missing xcom functions on hook KPO to tolerate missing xcom config functions on hook May 12, 2023
Comment on lines +887 to +890
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I think that it would be better to replace these two if statements with one if isinstance(self.hook, GKEPodHook). For the long term, maybe we should consider refactoring the abstraction.
  2. Is it possible to unit test it? If so, it would be nice to implement.

Copy link
Member

@hussein-awala hussein-awala left a 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?

@dstandish
Copy link
Contributor Author

Protocol added here #31298

@dstandish
Copy link
Contributor Author

don't think we need this one anymore given #31266 and #31298

@dstandish dstandish closed this May 16, 2023
@jedcunningham jedcunningham deleted the kpo-tolerate-missing-xcom-functions-on-hook branch June 12, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:cncf-kubernetes Kubernetes provider related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants