Use upper-constraints in the Tobiko ansible roles

In Tobiko we have roles to e.g. ensure that tox is installed. It uses
pip but it didn't use upper-constraints.txt file from the OpenStack
requirements and that could cause some issues, especially on e.g. older
operating systems, see related bug for example.

With this patch those ansible roles which uses pip to install some
python packages will use upper-constraints file if it exists in the file
system (in the u/s CI it will exist).

Depends-On: https://review.opendev.org/c/x/devstack-plugin-tobiko/+/912740

Closes-Bug: #2057492
Change-Id: I147770a7949c59ba61b8dcca23d5c6fbbacb2606
This commit is contained in:
Slawek Kaplonski 2024-03-13 09:32:44 +01:00
parent 7733488f00
commit 4945c52c73
4 changed files with 27 additions and 4 deletions

View File

@ -1,8 +1,16 @@
---
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "ensure Bindep is installed"
command: >
'{{ python_executable }}' -m pip install --user 'bindep>={{ bindep_min_version }}'
'{{ python_executable }}' -m pip install \
{% if upper_constraints_file.stat.exists == true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %} \
--user bindep>='{{ bindep_min_version }}'
register: install_bindep
changed_when: "'Successfully installed' in install_bindep.stdout"

View File

@ -18,6 +18,8 @@ test_project:
test_git_repo: '{{ git_base }}/x/tobiko.git'
test_src_dir: ''
openstack_requirements_dir: "/opt/stack/requirements"
# NOTE: if test_dir and tobiko_dir variables endup being the same actual
# directory then test_src and test_git_* variables will be overriden

View File

@ -57,10 +57,17 @@
failed_when: (python_info | length) == 0
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "upgrade '{{ python_command }}' packages to the latest versions"
command: >
'{{ python_info[python_command].executable }}' -m pip install '{{ item }}' \
--upgrade --user
'{{ python_info[python_command].executable }}' -m pip install \
{% if upper_constraints_file.stat.exists == true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %}
'{{ item }}' --upgrade --user
register: upgrade_python_packages
changed_when:
"'Successfully installed' in upgrade_python_packages.stdout"

View File

@ -1,8 +1,14 @@
---
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "ensure Tox is installed"
command: >
{{ python_executable }} -m pip install --user
'{{ python_executable }}' -m pip install {% if upper_constraints_file.stat.exists is true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %}--user \
'tox>={{ tox_min_version }}{% if tox_max_version is not none %},<={{ tox_max_version }}{% endif %}'
register: install_tox
changed_when: "'Successfully installed' in install_tox.stdout"