EC2: match all security groups when filtering describe_instances - #10145
Open
Sanjays2402 wants to merge 1 commit into
Open
EC2: match all security groups when filtering describe_instances#10145Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
describe_instances filtered by group-id, instance.group-id or instance.group-name only matched an instance's first security group, so an instance belonging to several groups was wrongly excluded when filtered by any of the others. get_object_value() returned as soon as the first list element produced a value, so for a list-valued attribute such as security_groups only that element's value reached instance_value_in_filter_values(). It now collects the value of every element and returns the full list (or None when empty), which the filter comparison already handles via its list branch. Adds test_get_instances_filtering_by_secondary_instance_group covering the three affected filters plus the first group, which fails without the fix. Closes getmoto#10114
Contributor
|
Duplicates #10115 |
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.
Closes #10114
describe_instancesfiltered bygroup-id,instance.group-idorinstance.group-nameonly matched an instance's first security group, so an instance in several groups was wrongly excluded when filtered by any of the others.get_object_value()returned as soon as the first list element produced a value, so for a list-valued attribute likesecurity_groupsonly that element's value reachedinstance_value_in_filter_values(). It now collects the value of every element and returns the full list (orNonewhen empty), which the filter comparison already handles via its list branch.test_get_instances_filtering_by_secondary_instance_groupcovers the three affected filters plus the first group; it fails on master and passes with the fix.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.