Add distro/arch to requirements file path

This addresses an issue when upgrading between different operating
systems. In this case, the requirements files already exist for
the old OS, which prevents new wheels from being created for the
new OS. By using a different requirements path for each OS this is
avoided.

As part of this, repeated variable construction for the
requirements path is factored our into a vars file.

Change-Id: I881a40fee31df78bf96e451509671543a49520d9
This commit is contained in:
Andrew Bonney 2021-07-22 09:22:17 +01:00
parent 1f69673fe2
commit 680a728876
5 changed files with 28 additions and 17 deletions

View File

@ -78,7 +78,7 @@ venv_pip_build_args: ""
# the venv.
venv_default_pip_install_args: >-
{%- if (groups['repo_all'] is defined) and (groups['repo_all'] | length > 0) and (venv_wheel_build_enable | bool) %}
--find-links {{ openstack_repo_url | default('http://localhost') }}/os-releases/{{ openstack_release | default('master') }}/{{ (ansible_facts['distribution'] | lower) | replace(' ', '_') }}-{{ ansible_facts['distribution_version'].split('.')[:2] | join('.') }}-{{ ansible_facts['architecture'] | lower }}
--find-links {{ openstack_repo_url | default('http://localhost') }}/os-releases/{{ openstack_release | default('master') }}/{{ _venv_build_dist_arch }}/wheels
--trusted-host {{ (openstack_repo_url | default('http://localhost')) | urlsplit('hostname') }}
{%- endif %}
@ -133,7 +133,7 @@ venv_build_host_venv_path: "/openstack/venvs/wheel-builder-{{ venv_python_execut
# on the build host in order to ensure the build process
# is idempotent.
venv_build_host_requirements_path: >-
/var/www/repo/os-releases/{{ openstack_release | default('master') }}
/var/www/repo/os-releases/{{ openstack_release | default('master') }}/{{ _venv_build_dist_arch }}/requirements
# The path where the wheels are cached on the build host
# for speeding up the build process.
@ -145,7 +145,7 @@ venv_build_host_requirements_path: >-
# been found that pypiserver hangs when it encounters duplicated
# wheels.
venv_build_host_wheel_path: >-
/var/www/repo/os-releases/{{ openstack_release | default('master') }}/{{ (ansible_facts['distribution'] | lower) | replace(' ', '_') }}-{{ ansible_facts['distribution_version'].split('.')[:2] | join('.') }}-{{ ansible_facts['architecture'] | lower }}
/var/www/repo/os-releases/{{ openstack_release | default('master') }}/{{ _venv_build_dist_arch }}/wheels
# The facts to set when the venv changes during a
# build, or the installation of a venv.

View File

@ -0,0 +1,7 @@
---
fixes:
- |
This release addresses an issue which could cause wheels to fail to be
built when upgrading from one operating system to another. Upgrading to
this release is recommended before attempting an operating system
upgrade.

View File

@ -17,7 +17,7 @@
delegate_to: "{{ venv_build_host }}"
become: "{{ venv_build_host == 'localhost' }}"
slurp:
src: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-constraints.txt"
src: "{{ _venv_build_requirements_prefix }}-constraints.txt"
register: _constraints_file_slurp
run_once: true
when: venv_wheel_build_enable | bool

View File

@ -36,10 +36,10 @@
path: "{{ item }}"
state: absent
with_items:
- "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-requirements.txt"
- "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-global-constraints.txt"
- "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-source-constraints.txt"
- "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-constraints.txt"
- "{{ _venv_build_requirements_prefix }}-requirements.txt"
- "{{ _venv_build_requirements_prefix }}-global-constraints.txt"
- "{{ _venv_build_requirements_prefix }}-source-constraints.txt"
- "{{ _venv_build_requirements_prefix }}-constraints.txt"
when:
- venv_rebuild | bool
@ -72,7 +72,7 @@
- name: Build requirements file for the venv
copy:
dest: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-requirements.txt"
dest: "{{ _venv_build_requirements_prefix }}-requirements.txt"
content: |
{% for item in _venv_pip_packages %}
{{ item }}
@ -83,7 +83,7 @@
- name: Build global constraints file for the venv
copy:
dest: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-global-constraints.txt"
dest: "{{ _venv_build_requirements_prefix }}-global-constraints.txt"
content: |
{% for item in venv_build_global_constraints %}
{{ item }}
@ -94,7 +94,7 @@
- name: Build constraints file for the venv
copy:
dest: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-source-constraints.txt"
dest: "{{ _venv_build_requirements_prefix }}-source-constraints.txt"
content: |
{% for item in venv_build_constraints %}
{{ item }}
@ -112,8 +112,8 @@
state: "{{ venv_pip_package_state }}"
virtualenv: "{{ venv_build_host_venv_path }}"
extra_args: >-
--constraint {{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-global-constraints.txt
--constraint {{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-source-constraints.txt
--constraint {{ _venv_build_requirements_prefix }}-global-constraints.txt
--constraint {{ _venv_build_requirements_prefix }}-source-constraints.txt
--find-links {{ venv_build_host_wheel_path }}/
--log /var/log/python_venv_build.log
{{ venv_pip_build_args }}
@ -135,9 +135,9 @@
- name: Build wheels for the packages to be installed into the venv
command: >-
{{ venv_build_host_venv_path }}/bin/pip wheel
--requirement {{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-requirements.txt
--constraint {{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-global-constraints.txt
--constraint {{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-source-constraints.txt
--requirement {{ _venv_build_requirements_prefix }}-requirements.txt
--constraint {{ _venv_build_requirements_prefix }}-global-constraints.txt
--constraint {{ _venv_build_requirements_prefix }}-source-constraints.txt
--wheel-dir /tmp/{{ venv_install_destination_path | basename }}/
--find-links {{ venv_build_host_wheel_path }}/
--log /var/log/python_wheel_build.log
@ -176,6 +176,6 @@
{% set file_name = file_data['path'] | basename %}
{{ file_name.split('-')[0] | lower }}=={{ (file_name.split('-')[1].split('_')) | join('.post') | lower }}
{% endfor %}
dest: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}-constraints.txt"
dest: "{{ _venv_build_requirements_prefix }}-constraints.txt"
owner: "{{ venv_build_host_user_name | default(omit) }}"
group: "{{ venv_build_host_group_name | default(omit) }}"

View File

@ -70,3 +70,7 @@ venv_build_targets: |-
{{ targets }}
_venv_pip_packages: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort | select | list }}"
_venv_build_dist_arch: "{{ (ansible_facts['distribution'] | lower) | replace(' ', '_') }}-{{ ansible_facts['distribution_version'].split('.')[:2] | join('.') }}-{{ ansible_facts['architecture'] | lower }}"
_venv_build_requirements_prefix: "{{ venv_build_host_requirements_path }}/{{ venv_install_destination_path | basename }}"