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

inventory: Handle IndexError while parsing limit file #59776

Merged
merged 1 commit into from
Jul 30, 2019

Conversation

Akasurde
Copy link
Member

SUMMARY

Handle IndexError exception raised while parsing the limit file.

Fixes: #59695

Signed-off-by: Abhijeet Kasurde akasurde@redhat.com

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

changelogs/fragments/limit_file_parsing.yml
lib/ansible/inventory/manager.py
test/integration/targets/inventory/runme.sh

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. inventory Inventory category needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 30, 2019
@@ -69,9 +69,9 @@ def order_patterns(patterns):
pattern_intersection = []
pattern_exclude = []
for p in patterns:
if p[0] == "!":
Copy link
Member

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

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jul 30, 2019
@@ -69,9 +69,9 @@ def order_patterns(patterns):
pattern_intersection = []
pattern_exclude = []
for p in patterns:
if p[0] == "!":
if p and p[0] == "!":
Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@bcoca +1, I should've refreshed before commenting ;-)

Still, not for this PR but we should audit #58400 for similar possibilities of IndexError.

Handle IndexError exception raised while parsing the limit file.

Fixes: ansible#59695

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 30, 2019
@Akasurde Akasurde requested review from mkrizek and bcoca July 30, 2019 16:01
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 30, 2019
@bcoca bcoca merged commit 2ebc4e1 into ansible:devel Jul 30, 2019
@Akasurde Akasurde deleted the i59695 branch July 31, 2019 02:26
@ansible ansible locked and limited conversation to collaborators Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. inventory Inventory category support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERROR! Unexpected Exception, this is probably a bug: string index out of range
4 participants