From 4a04d08eb4f10162a92c84f1fc543e7b110f53f8 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 15 Sep 2022 17:44:05 +0200 Subject: [PATCH] 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/+/858258 Change-Id: I762e36acf76729fd61f28ca1b03bc9f562b5db0a --- defaults/main.yml | 4 +++- vars/main.yml | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 87c6cf4..e06c94d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/vars/main.yml b/vars/main.yml index 008fe91..e1dcdab 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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 }}"