tripleo-ansible-inventory is very slow

Bug #1689789 reported by Michele Baldessari
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
Medium
Florian Fuchs

Bug Description

(undercloud) [stack@undercloud ~]$ time tripleo-ansible-inventory --list
{"overcloud": {"children": ["controller", "compute"], "vars": {"ansible_ssh_user": "heat-admin"}}, "controller": ["192.168.24.14", "192.168.24.18", "192.168.24.12"], "undercloud": {"hosts": ["localhost"], "vars": {"overcloud_horizon_url": "http://[2001:db8:fd00:1000::19]:80/dashboard", "overcloud_admin_password": "sPCZZYxzJv6XTCfWRGdavJbB9", "ansible_connection": "local"}}, "compute": ["192.168.24.10"]}

real 1m0.176s
user 0m1.797s
sys 0m0.108s

So it takes a whole minute just to list an inventory. This makes it very suboptimal to use.

I think we can improve on two fronts here:
1) Add an option to dump the inventory as a proper ansible inventory file. So I can do "ansible -i inventory-file-dump -m ping" and generally run ansible commands without having to wait a whole minute every time.

2) Speed up the query. I have added a bit of timing calls:
(undercloud) [stack@undercloud ~]$ time tripleo-ansible-inventory --list
_parse_config start: 1494411583.93
_parse_config end: 1494411583.93
list start: 1494411583.93
get_overcloud_output start: 1494411583.93
get_overcloud_output end: 1494411596.07
get_overcloud_output start: 1494411596.07
get_overcloud_output end: 1494411607.26
get_overcloud_environment start: 1494411607.26
get_overcloud_environment end: 1494411608.54
get_overcloud_output start: 1494411608.54
get_overcloud_output end: 1494411619.67
fetch_stack_resources -> Controller
fetch_stack_resources start: 1494411619.67
fetch_stack_resources end: 1494411639.81
fetch_stack_resources -> Compute
fetch_stack_resources start: 1494411639.81
fetch_stack_resources end: 1494411642.13
list end: 1494411642.13
{"overcloud": {"children": ["controller", "compute"], "vars": {"ansible_ssh_user": "heat-admin"}}, "controller": ["192.168.24.14", "192.168.24.18", "192.168.24.12"], "undercloud": {"hosts": ["localhost"], "vars": {"overcloud_horizon_url": "http://[2001:db8:fd00:1000::19]:80/dashboard", "overcloud_admin_password": "sPCZZYxzJv6XTCfWRGdavJbB9", "ansible_connection": "local"}}, "compute": ["192.168.24.10"]}

real 0m58.857s
user 0m1.784s
sys 0m0.094s

So we can probably use a single get_overcloud_output call and then use the results? Or look into optimizing the fetch_stack_resources call?

Revision history for this message
Florian Fuchs (flo-fuchs) wrote :

This patch adds some optimizations to the inventory: https://review.openstack.org/#/c/450233/

Changed in tripleo:
assignee: nobody → Florian Fuchs (flo-fuchs)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-validations (master)

Reviewed: https://review.openstack.org/450233
Committed: https://git.openstack.org/cgit/openstack/tripleo-validations/commit/?id=9461adfa244793cba91f87fcee25a6887a9b7368
Submitter: Jenkins
Branch: master

commit 9461adfa244793cba91f87fcee25a6887a9b7368
Author: Florian Fuchs <email address hidden>
Date: Mon Mar 27 15:47:36 2017 +0200

    Show all roles in inventory

    This patch updates the tripleo-ansible-inventory to show all roles in
    the host list, not just compute and controller nodes.

    The retrieval of IPs and stack outputs is slightly refactored: Instead of
    retrieving them from Nova, the host IPs are now read from the stacks new
    RoleNetIpMap output. The stack outputs are fetched from heat via a new
    `StackOutputs` class that ensures outputs are only fetched when needed.

    Closes-Bug: #1685544
    Closes-Bug: #1689789
    Change-Id: Ic8a19f15dd45b383a3f3d403653e3eaef2c1865b

Changed in tripleo:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-validations (stable/ocata)

Reviewed: https://review.openstack.org/463726
Committed: https://git.openstack.org/cgit/openstack/tripleo-validations/commit/?id=54d7ff11d99939933bbd41e9c6e7fffd39a8930b
Submitter: Jenkins
Branch: stable/ocata

commit 54d7ff11d99939933bbd41e9c6e7fffd39a8930b
Author: Florian Fuchs <email address hidden>
Date: Wed May 10 11:39:16 2017 +0000

    Improve performance when fetching outputs

    Stack outputs where fetched via `heat_client.stacks.get(...)` which
    proved to be fairly slow.

    This patch changes output fetching to use
    `heat_client.stacks.output_show(...)` instead.

    Partial-Bug: #1689789
    Change-Id: I751400d414d17a39715aa33d0a8b323ed1211643

tags: added: in-stable-ocata
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to tripleo-validations (master)

Reviewed: https://review.openstack.org/463912
Committed: https://git.openstack.org/cgit/openstack/tripleo-validations/commit/?id=b9993635c1a84b2de67bfaf07520dea53f422770
Submitter: Jenkins
Branch: master

commit b9993635c1a84b2de67bfaf07520dea53f422770
Author: Juan Antonio Osorio Robles <email address hidden>
Date: Thu May 11 05:09:58 2017 +0000

    Pass printing responsibility to dynamic inventory script

    The class object now just returns the dict, and the responsibility
    of printing the json object is now part of the dynamic inventory
    script. This separation was done so in a further commit, more options
    can be passed to this script.

    Related-Bug: #1689789
    Change-Id: I51dfd8618b88bcd2d28dbc799dbb4820c6055705

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/463913
Committed: https://git.openstack.org/cgit/openstack/tripleo-validations/commit/?id=834d014e8965cc8f0ee2d8822200d6deee397ec1
Submitter: Jenkins
Branch: master

commit 834d014e8965cc8f0ee2d8822200d6deee397ec1
Author: Juan Antonio Osorio Robles <email address hidden>
Date: Thu May 11 05:57:23 2017 +0000

    Add ability to write static inventory

    In some cases it might be useful to just have a static inventory,
    since bigger deployments might take a long time to process each
    time. This enables the option --static-inventory to the
    tripleo-ansible-inventory script, which does just this.

    Related-Bug: #1689789
    Change-Id: I96a6b1bc17035b116a85e4e560452321123551dc

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to tripleo-validations (stable/ocata)

Related fix proposed to branch: stable/ocata
Review: https://review.openstack.org/463924

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to tripleo-validations (stable/ocata)

Reviewed: https://review.openstack.org/463924
Committed: https://git.openstack.org/cgit/openstack/tripleo-validations/commit/?id=8e7ccad77ca0ac07c1669ada89c368d0457b9bcb
Submitter: Jenkins
Branch: stable/ocata

commit 8e7ccad77ca0ac07c1669ada89c368d0457b9bcb
Author: Juan Antonio Osorio Robles <email address hidden>
Date: Thu May 11 05:57:23 2017 +0000

    Add ability to write static inventory

    In some cases it might be useful to just have a static inventory,
    since bigger deployments might take a long time to process each
    time. This enables the option --static-inventory to the
    tripleo-ansible-inventory script, which does just this.

    Conflicts:
     scripts/tripleo-ansible-inventory

    Related-Bug: #1689789
    Change-Id: I96a6b1bc17035b116a85e4e560452321123551dc
    (cherry picked from commit 834d014e8965cc8f0ee2d8822200d6deee397ec1)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-validations 7.1.0

This issue was fixed in the openstack/tripleo-validations 7.1.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.