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

Fix EC2Hook get_instance for client_type api #35960

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

hussein-awala
Copy link
Member

The method get_instance should return a single instance and not a list.

@@ -85,7 +85,7 @@ def get_instance(self, instance_id: str, filters: list | None = None):
:return: Instance object
"""
if self._api_type == "client_type":
return self.get_instances(filters=filters, instance_ids=[instance_id])
return self.get_instances(filters=filters, instance_ids=[instance_id])[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is not it breaking change? Or we consider it as bug fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

For me, it's a bug fix. We can check with @eladkal.

Copy link
Member

Choose a reason for hiding this comment

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

The method seems to return a single instance with the default api_type="resource_type". Similarly, this method should return a single instance for other api_types, so I would treat it as a bug fix. Also, it's named as get_instance so the expectation would be a single instance to be returned.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would classify this as bug fix

@@ -85,7 +85,7 @@ def get_instance(self, instance_id: str, filters: list | None = None):
:return: Instance object
"""
if self._api_type == "client_type":
return self.get_instances(filters=filters, instance_ids=[instance_id])
return self.get_instances(filters=filters, instance_ids=[instance_id])[0]
Copy link
Member

Choose a reason for hiding this comment

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

The method seems to return a single instance with the default api_type="resource_type". Similarly, this method should return a single instance for other api_types, so I would treat it as a bug fix. Also, it's named as get_instance so the expectation would be a single instance to be returned.

@hussein-awala
Copy link
Member Author

Thanks to all of you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants