KPO to tolerate missing xcom config functions on hook#31258
Closed
dstandish wants to merge 2 commits intoapache:mainfrom
Closed
KPO to tolerate missing xcom config functions on hook#31258dstandish wants to merge 2 commits intoapache:mainfrom
dstandish wants to merge 2 commits intoapache:mainfrom
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.
shahar1
reviewed
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() |
Contributor
There was a problem hiding this comment.
- I think that it would be better to replace these two
ifstatements 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.
Member
hussein-awala
left a comment
There was a problem hiding this comment.
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?
Contributor
Author
|
Protocol added here #31298 |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.