-
Notifications
You must be signed in to change notification settings - Fork 23.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
inventory: Handle IndexError while parsing limit file #59776
Conversation
lib/ansible/inventory/manager.py
Outdated
@@ -69,9 +69,9 @@ def order_patterns(patterns): | |||
pattern_intersection = [] | |||
pattern_exclude = [] | |||
for p in patterns: | |||
if p[0] == "!": |
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.
instead of adding p on every condition, if not p: continue
would shortcut the whole thing
lib/ansible/inventory/manager.py
Outdated
@@ -69,9 +69,9 @@ def order_patterns(patterns): | |||
pattern_intersection = [] | |||
pattern_exclude = [] | |||
for p in patterns: | |||
if p[0] == "!": | |||
if p and p[0] == "!": |
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.
@sivel So this was introduced in #58400 and there are more changes where we replaced startswith
with checking the first index instead for perf purposes. I wonder if doing p and p[0]
over startswith
is still beneficial. Or, if we should filter empty patterns someplace up, in the code that calls this.
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.
@mkrizek see my comment above, checking if not p
would still be a net gain
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.
Handle IndexError exception raised while parsing the limit file. Fixes: ansible#59695 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
SUMMARY
Handle IndexError exception raised while parsing the limit file.
Fixes: #59695
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com
ISSUE TYPE
COMPONENT NAME
changelogs/fragments/limit_file_parsing.yml
lib/ansible/inventory/manager.py
test/integration/targets/inventory/runme.sh