Change default value for venv_wheel_build_enable

With fixing multi-distro support logic, venv_wheel_build_enable logic
stopped working for metal deployments, that have more then 1 host.
Currently, we were checking, that we are not building wheels if build_host
is the same as inventory_hostname. Which is now true for all metal
deployments. However, other hosts do expect wheels to present, which
results in installation failure.

According to the original idea we need to build wheels only when we have
more then 1 host with same arch/distro combination otherwise it does
not make sense to build wheels and faster to install tarball.

To achieve that we build mapping of all distro/arch combinations and
enable wheels building only when there distro-arch combination
is not unique for the host we're playing against.

Despite it might be overkill, as scenario of having only single host
with uniqe distro-arch combination, and overhead of building wheels for
it would be quite small, alternative would be to hardcode `True` for
venv_wheel_build_enable.

Closes-Bug: #1989506
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-os_placement/+/859162
Change-Id: I762e36acf76729fd61f28ca1b03bc9f562b5db0a
(cherry picked from commit 4a04d08eb4)
This commit is contained in:
Dmitriy Rabotyagov 2022-09-15 17:44:05 +02:00 committed by Dmitriy Rabotyagov
parent 9b95a1e8fd
commit 8a9ababb80
2 changed files with 19 additions and 6 deletions

View File

@ -116,7 +116,9 @@ venv_wheels_rebuild: no
# If the package concerned is built from a tarball, rather
# than from a git source or pypi, then this may be best to
# set to false.
venv_wheel_build_enable: "{{ venv_build_host != inventory_hostname }}"
# Default: Enabled when more then 1 host with same arch/distro
# is in play
venv_wheel_build_enable: "{{ _venv_wheel_build_enable }}"
# Set the host where the wheels will be built.
# If this host is not the same as the target host, then

View File

@ -56,17 +56,28 @@ venv_build_targets: |-
{% endfor %}
{{ targets }}
_venv_wheels_first_play_hosts: |
{% set first_hosts = {} %}
_venv_wheels_play_hosts: |
{% set wheel_groups = {} %}
{% for host in ansible_play_hosts %}
{% set arch = hostvars[host]['ansible_facts']['architecture'] %}
{% set distro = hostvars[host]['ansible_facts']['distribution_version'] %}
{% set distro_arch = [distro, arch] | join('_') %}
{% if distro_arch not in first_hosts %}
{% set _ = first_hosts.update({distro_arch: host}) %}
{% if distro_arch not in wheel_groups %}
{% set _ = wheel_groups.update({distro_arch: [host]}) %}
{% else %}
{% set _ = wheel_groups[distro_arch].append(host) %}
{% endif %}
{% endfor %}
{{ first_hosts.values() }}
{{ wheel_groups }}
_venv_wheels_first_play_hosts: |
{% set first_hosts = [] %}
{% for distro_arch_hosts in _venv_wheels_play_hosts.values() %}
{% set _ = first_hosts.append(distro_arch_hosts | first) %}
{% endfor %}
{{ first_hosts }}
_venv_wheel_build_enable: "{{ (_venv_wheels_play_hosts[ansible_facts['distribution_version'] ~ '_' ~ ansible_facts['architecture']] | length > 1) | bool }}"
_venv_pip_packages: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort | select | list }}"