3e03884c47
For overcloud commands involving Bifrost (e.g. overcloud provision), we use the Bifrost dynamic inventory. This runs bifrost_inventory.py which gathers node and port information for all bare metal hosts. Because this gets executed for each node in our inventory, it produces a large number of API requests to Ironic, which grows as the number of hosts increases. Halve the number of calls using the BIFROST_NODE_NAMES environment variable, which restricts fetching port information to just the node being queried. bifrost_inventory.py still performs one call for each node, which must be fixed separately in Bifrost [1]. Time to query overcloud nodes' hardware introspection data for 44 hosts: * before patch: 823 seconds * after patch: 415 seconds With the patch to Bifrost [1], this is further reduced to 46 seconds. [1] https://review.opendev.org/c/openstack/bifrost/+/882950 Change-Id: I341075115442a38c327e3ade74b81b1b9e7e85c6
63 lines
2.4 KiB
YAML
63 lines
2.4 KiB
YAML
---
|
|
- name: Ensure the overcloud nodes' hardware introspection data is saved
|
|
hosts: overcloud
|
|
vars:
|
|
seed_host: "{{ groups['seed'][0] }}"
|
|
# Override this to save results to another location.
|
|
output_dir: "{{ lookup('env', 'PWD') }}/overcloud-introspection-data"
|
|
# Override this to set the output data format. One of json, yaml.
|
|
output_format: json
|
|
gather_facts: no
|
|
tasks:
|
|
- name: Query overcloud nodes' hardware introspection data
|
|
command: >
|
|
docker exec bifrost_deploy
|
|
bash -c '
|
|
env BIFROST_INVENTORY_SOURCE=ironic BIFROST_NODE_NAMES="{{ inventory_hostname }}" OS_CLOUD=bifrost
|
|
ansible baremetal
|
|
--connection local
|
|
--inventory /etc/bifrost/inventory/
|
|
-e @/etc/bifrost/bifrost.yml
|
|
-e @/etc/bifrost/dib.yml
|
|
--limit {{ inventory_hostname }}
|
|
-m shell
|
|
-a "env OS_CLOUD=bifrost baremetal introspection data save {% raw %}{{ inventory_hostname }}{% endraw %}"'
|
|
register: save_result
|
|
changed_when: False
|
|
# Ignore errors, log a message later.
|
|
failed_when: False
|
|
delegate_to: "{{ seed_host }}"
|
|
vars:
|
|
# NOTE: Without this, the seed's ansible_host variable will not be
|
|
# respected when using delegate_to.
|
|
ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}"
|
|
|
|
- name: Ensure introspection data output directory exists
|
|
local_action:
|
|
module: file
|
|
path: "{{ output_dir }}"
|
|
state: directory
|
|
|
|
- name: Ensure introspection data is saved locally
|
|
local_action:
|
|
module: copy
|
|
content: "{{ introspection_data_map[output_format | lower] }}"
|
|
dest: "{{ output_dir }}/{{ inventory_hostname }}.{{ output_format | lower }}"
|
|
when: save_result.rc == 0
|
|
vars:
|
|
introspection_data: "{{ save_result.stdout_lines[1:] | join('\n') | from_json }}"
|
|
introspection_data_json: "{{ introspection_data | to_nice_json(indent=4) }}"
|
|
introspection_data_yaml: "{{ introspection_data | to_nice_yaml }}"
|
|
introspection_data_map:
|
|
json: "{{ introspection_data_json }}"
|
|
yaml: "{{ introspection_data_yaml }}"
|
|
|
|
- name: Log when introspection data could not be queried
|
|
debug:
|
|
msg: >
|
|
Could not query hardware introspection data for
|
|
{{ inventory_hostname }}.
|
|
Stdout: {{ save_result.stdout }}.
|
|
Stderr: {{ save_result.stderr }}.
|
|
when: save_result.rc != 0
|