Skip to content

Commit bd4542f

Browse files
committed
[CI] Fix bootstrap testing
This patch adjusts the CI in such a way that we can finally test the correctness of bootstrap-servers. - It correctly installs the virtualenv at the beginning - It sets ansible_python_interpreter to this virtualenv - It runs bootstrap-servers between upgrades - It moves package installation from the CI playbook to ansible-collections-kolla To summarize: this patch aligns behavior and tests the code within the boundaries it should be tested in - that is, inside a virtualenv. This naturally also tests the correctness of ansible-collection-kolla, which installs packages and other dependencies (now not mixed with OS py interpreter). This is important, especially due to a bug in older versions of Docker and requests, which required running bootstrap-servers. Proof of this is that the rocky9-octavia job is finally working, with no more issues with package cryptography (which was read from OS python environment by ansible). TL;DR: From now on, it runs correctly inside a virtualenv, and the OS interpreter no longer interferes. Depends-On: https://review.opendev.org/c/openstack/ansible-collection-kolla/+/946983 Change-Id: Ifea75c2e14ffececbe271bee1549e92bded90d48
1 parent 26b1bc0 commit bd4542f

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

tests/run.yml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
upper_constraints_file: "{{ ansible_env.HOME }}/src/opendev.org/openstack/requirements/upper-constraints.txt"
2727
docker_image_tag_suffix: "{{ '-aarch64' if ansible_architecture == 'aarch64' else '' }}"
2828
kolla_ansible_venv_path: "{{ ansible_env.HOME }}/kolla-ansible-venv"
29+
kolla_runtime_venv_path: "{{ ansible_env.HOME }}/kolla-runtime-venv"
2930
kolla_internal_fqdn: "kolla.example.com"
3031

3132
- name: Install dig for Designate testing
@@ -52,6 +53,30 @@
5253
when:
5354
- scenario == "lets-encrypt"
5455

56+
# NOTE(kevko): Rocky Linux has Python 3.9 as the default, but we want to use Python 3.12 instead.
57+
- name: Install Python3.12 and dependencies on RHEL derivatives
58+
dnf:
59+
name:
60+
- python3.12
61+
- python3.12-devel
62+
- python3.12-pip
63+
state: latest
64+
when: ansible_facts.os_family == 'RedHat'
65+
become: true
66+
67+
# NOTE(kevko): While in Rocky, virtualenv is included as part of the packages above, in Debuntu, virtualenv is in a separate package.
68+
- name: Install python3-virtualenv
69+
package:
70+
name: python3-virtualenv
71+
state: present
72+
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}"
73+
become: true
74+
when: ansible_facts.os_family != 'RedHat'
75+
76+
- name: Create Kolla runtime venv
77+
command:
78+
cmd: "{{ 'python3.12' if ansible_facts.os_family == 'RedHat' else 'python3' }} -m venv {{ kolla_runtime_venv_path }}"
79+
creates: "{{ kolla_runtime_venv_path }}"
5580

5681
- hosts: primary
5782
any_errors_fatal: true
@@ -236,37 +261,11 @@
236261
state: directory
237262
become: true
238263

239-
- name: Install Python3.12 and dependencies needed for dbus-python on RHEL derivatives
240-
dnf:
241-
name:
242-
- python3.12
243-
- python3.12-devel
244-
- python3.12-pip
245-
- gcc
246-
- dbus-devel
247-
- glib2-devel
248-
- dbus-x11
249-
state: latest
250-
when: ansible_facts.os_family == 'RedHat'
251-
become: true
252-
253264
- name: Create Kolla Ansible venv
254265
command:
255266
cmd: "{{ 'python3.12' if ansible_facts.os_family == 'RedHat' else 'python3' }} -m venv {{ kolla_ansible_venv_path }}"
256267
creates: "{{ kolla_ansible_venv_path }}"
257268

258-
- name: Ensure the latest tested pip
259-
pip:
260-
name: "pip==23.*"
261-
state: latest
262-
virtualenv: "{{ kolla_ansible_venv_path }}"
263-
264-
- name: Ensure the latest tested setuptools
265-
pip:
266-
name: "setuptools==67.2.0"
267-
state: latest
268-
virtualenv: "{{ kolla_ansible_venv_path }}"
269-
270269
- name: Install kolla-ansible and dependencies
271270
pip:
272271
extra_args: "-c {{ upper_constraints_file }}"

tests/templates/globals-default.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
ansible_python_interpreter: /usr/bin/python3
2+
virtualenv: "{{ kolla_runtime_venv_path }}"
3+
ansible_python_interpreter: "{{ kolla_runtime_venv_path }}/bin/python"
34

45
kolla_base_distro: "{{ base_distro }}"
56
network_interface: "{{ api_interface_name }}"

tests/upgrade.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ function upgrade {
1313
source $KOLLA_ANSIBLE_VENV_PATH/bin/activate
1414

1515
kolla-ansible certificates -i ${RAW_INVENTORY} -vvv &> /tmp/logs/ansible/certificates
16+
# Previous versions had older docker, requests requirements for example
17+
# Therefore we need to run bootstrap again to ensure libraries are in
18+
# proper versions (ansible-collection-kolla is different for new version, potentionally
19+
# also dependencies).
20+
kolla-ansible bootstrap-servers -i ${RAW_INVENTORY} -vvv &> /tmp/logs/ansible/upgrade-bootstrap
1621
# Skip rabbitmq-ha-precheck before the queues are migrated.
1722
kolla-ansible prechecks -i ${RAW_INVENTORY} --skip-tags rabbitmq-ha-precheck -vvv &> /tmp/logs/ansible/upgrade-prechecks-pre-rabbitmq
1823

0 commit comments

Comments
 (0)