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

Account for empty strings when splitting the host pattern #62442

Merged
merged 5 commits into from Sep 20, 2019

Conversation

samdoran
Copy link
Contributor

SUMMARY

Filter out empty strings when returning the list of hosts from split_host_pattern().
Fixes #61964

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/inventory/manager.py

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. inventory Inventory category needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. 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 Sep 17, 2019
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@s-hertel s-hertel left a comment

Choose a reason for hiding this comment

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

shipit

Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

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

behaviour pre 2.9 (i checked 2.8-2.4) was always '' == ',', which this restores

lib/ansible/inventory/manager.py Show resolved Hide resolved
- add more unit test cases
- add specific integration test with more cases
@ansibot
Copy link
Contributor

ansibot commented Sep 18, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/inventory/manager.py:135:1: E302: expected 2 blank lines, found 1

click here for bot help

Testing shows no major downside to calling .strip() twice in a comprehnios vs. using a regular for loop and only calling .strip() once. Going with the comprehension for ease of maintenance and because comprehensions are optimized in CPython.
@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Sep 19, 2019
@samdoran samdoran merged commit 987265a into ansible:devel Sep 20, 2019
@samdoran samdoran deleted the issue/61964-limit-comma-split branch September 20, 2019 20:03
samdoran added a commit to samdoran/ansible that referenced this pull request Sep 20, 2019
ansible#62442)

Improve tests
- add more unit test cases
- add specific integration test with more cases

Testing shows no major downside to calling .strip() twice in a comprehension vs. using a regular for loop and only calling .strip() once. Going with the comprehension for ease of maintenance and because comprehensions are optimized in CPython.
(cherry picked from commit 987265a)

Co-authored-by: Sam Doran <sdoran@redhat.com>
anas-shami pushed a commit to anas-shami/ansible that referenced this pull request Sep 23, 2019
)

Improve tests
- add more unit test cases
- add specific integration test with more cases

Testing shows no major downside to calling .strip() twice in a comprehension vs. using a regular for loop and only calling .strip() once. Going with the comprehension for ease of maintenance and because comprehensions are optimized in CPython.
@ansible ansible locked and limited conversation to collaborators Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. inventory Inventory category needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. 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.

Ansible crashes when --limit expression includes superfluous comma
6 participants