From 680a72887656515c928c3d767ff68a01ebb6df8c Mon Sep 17 00:00:00 2001 From: Andrew Bonney Date: Thu, 22 Jul 2021 09:22:17 +0100 Subject: [PATCH] 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 --- defaults/main.yml | 6 ++--- ...ade-requirements-fix-bcc81b049339e9b5.yaml | 7 +++++ tasks/python_venv_install.yml | 2 +- tasks/python_venv_wheel_build.yml | 26 +++++++++---------- vars/main.yml | 4 +++ 5 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 releasenotes/notes/os-upgrade-requirements-fix-bcc81b049339e9b5.yaml diff --git a/defaults/main.yml b/defaults/main.yml index cb4c305..289008a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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. diff --git a/releasenotes/notes/os-upgrade-requirements-fix-bcc81b049339e9b5.yaml b/releasenotes/notes/os-upgrade-requirements-fix-bcc81b049339e9b5.yaml new file mode 100644 index 0000000..cdb2783 --- /dev/null +++ b/releasenotes/notes/os-upgrade-requirements-fix-bcc81b049339e9b5.yaml @@ -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. diff --git a/tasks/python_venv_install.yml b/tasks/python_venv_install.yml index 58f8688..3a2d258 100644 --- a/tasks/python_venv_install.yml +++ b/tasks/python_venv_install.yml @@ -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 diff --git a/tasks/python_venv_wheel_build.yml b/tasks/python_venv_wheel_build.yml index ae078a6..7cd9c3f 100644 --- a/tasks/python_venv_wheel_build.yml +++ b/tasks/python_venv_wheel_build.yml @@ -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) }}" diff --git a/vars/main.yml b/vars/main.yml index 31359d8..38ae673 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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 }}"