Skip to content

Commit

Permalink
Try to get a faster reproducer role
Browse files Browse the repository at this point in the history
By leveraging some `async` and reorganizing tasks and tags, we're now
able to get a slightly faster run of the role itself.
It's not really visible yet, mostly due to libvirt_manager being slow,
but a notable improvement is at the tags level:

running `ansible-playbook [...] --tags bootstrap_env,deploy_architecture`,
you'll be able to:
- ensure parameters are up-to-date on the controller-0
- go through the "deploy architecture" path

More work and doc will come once we're able to validate the various tag
combination.
  • Loading branch information
cjeanner authored and openshift-merge-bot[bot] committed Apr 3, 2024
1 parent 406ec17 commit 9f2ace7
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 56 deletions.
2 changes: 2 additions & 0 deletions roles/reproducer/tasks/configure_architecture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
when:
- cifmw_deploy_architecture | default(false) | bool
no_log: false
async: 7200 # 2h should be enough to deploy EDPM.
poll: 20
ansible.builtin.command:
cmd: "/home/zuul/deploy-architecture.sh"
26 changes: 25 additions & 1 deletion roles/reproducer/tasks/configure_computes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@
- cifmw_repo_setup_rhos_release_rpm is defined
block:
- name: Get rhos-release
ansible.builtin.import_tasks: rhos_release.yml
ansible.builtin.include_tasks: rhos_release.yml

- name: Configure rhos-release
register: _async_rhos_release
async: 120 # 2 minutes should be enough?
poll: 0
ansible.builtin.command:
cmd: "rhos-release {{ cifmw_repo_setup_rhos_release_args }}"

Expand All @@ -61,3 +64,24 @@
loop: "{{ cifmw_reproducer_compute_repos }}"
loop_control:
label: "{{ item.name }}"

- name: Ensure rhos-release is configured
become: true
when:
- _async_rhos_release.ansible_job_id is defined
block:
- name: Ensure async flag still exists
register: _async_flag
ansible.builtin.stat:
path: >-
/root/.ansible_async/{{ _async_rhos_release.ansible_job_id }}
- name: Ensure rhos-release task is over
when:
- _async_flag.stat.exists
ansible.builtin.async_status:
jid: "{{ _async_rhos_release.ansible_job_id }}"
register: _async_result
until: _async_result.finished
retries: 20
delay: 5
122 changes: 74 additions & 48 deletions roles/reproducer/tasks/configure_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,58 @@
loop:
- parameters
- artifacts
- name: Install custom CA if needed
ansible.builtin.import_role:
name: install_ca

- name: RHEL repository setup for ansible-controller
become: true
when:
- cifmw_repo_setup_rhos_release_rpm is defined
block:
- name: Get rhos-release
ansible.builtin.import_tasks: rhos_release.yml

- name: Create bundle for CRC
ansible.builtin.shell:
cmd: >-
set -o pipefail;
cat /etc/pki/ca-trust/source/anchors/* >
/etc/pki/ca-trust/source/anchors/rh.crt
creates: "/etc/pki/ca-trust/source/anchors/rh.crt"

- name: Tweak dnf configuration
become: true
community.general.ini_file:
no_extra_spaces: true
option: "{{ config.option }}"
path: "/etc/dnf/dnf.conf"
section: "{{ config.section | default('main') }}"
state: "{{ config.state | default(omit) }}"
value: "{{ config.value | default(omit) }}"
loop: "{{ cifmw_reproducer_dnf_tweaks }}"
loop_control:
label: "{{ config.option }}"
loop_var: 'config'

- name: Install some tools
become: true
async: 600 # 10 minutes should be enough
poll: 0
register: _async_pkg_install
ansible.builtin.package:
name:
- bash-completion
- git-core
- make
- podman
- python3-jmespath
- python3-netaddr
- python3-pip
- tmux
- vim
- wget
- jq

- name: Build job inventory for hook usage
tags:
Expand All @@ -48,6 +100,8 @@
- name: Push the MAC mapping data
tags:
- bootstrap
when:
- cifmw_libvirt_manager_mac_map is defined
ansible.builtin.copy:
dest: "{{ _ctl_reproducer_basedir }}/parameters/interfaces-info.yml"
content: "{{ cifmw_libvirt_manager_mac_map | to_nice_yaml }}"
Expand Down Expand Up @@ -150,7 +204,8 @@
state: directory
owner: zuul
group: zuul
mode: "0755"
mode: "0750"

- name: Inject kubeconfig content
when:
- _devscripts_kubeconfig is defined or _crc_kubeconfig is defined
Expand All @@ -164,7 +219,7 @@
}}
owner: zuul
group: zuul
mode: "0644"
mode: "0640"

- name: Inject kubeadmin-password if exists
when:
Expand Down Expand Up @@ -193,61 +248,32 @@
state: directory
mode: "0755"

- name: Tweak dnf configuration
- name: Ensure packages are installed
become: true
community.general.ini_file:
no_extra_spaces: true
option: "{{ config.option }}"
path: "/etc/dnf/dnf.conf"
section: "{{ config.section | default('main') }}"
state: "{{ config.state | default(omit) }}"
value: "{{ config.value | default(omit) }}"
loop: "{{ cifmw_reproducer_dnf_tweaks }}"
loop_control:
label: "{{ config.option }}"
loop_var: 'config'

- name: Install custom CA if needed
ansible.builtin.import_role:
name: install_ca

- name: RHEL repository setup for ansible-controller
become: true
when:
- cifmw_repo_setup_rhos_release_rpm is defined
block:
- name: Get rhos-release
ansible.builtin.import_tasks: rhos_release.yml
- name: Check if async file is still available
register: _async_flag
ansible.builtin.stat:
path: >-
/root/.ansible_async/{{ _async_pkg_install.ansible_job_id }}
- name: Create bundle for CRC
ansible.builtin.shell:
cmd: >-
set -o pipefail;
cat /etc/pki/ca-trust/source/anchors/* >
/etc/pki/ca-trust/source/anchors/rh.crt
creates: "/etc/pki/ca-trust/source/anchors/rh.crt"

- name: Install some tools
become: true
ansible.builtin.package:
name:
- bash-completion
- git-core
- make
- podman
- python3-jmespath
- python3-netaddr
- python3-pip
- tmux
- vim
- wget
- jq
- name: Check package install status
when:
- _async_flag.stat.exists
register: _async_status
ansible.builtin.async_status:
jid: "{{ _async_pkg_install.ansible_job_id }}"
until: _async_status.finished
retries: 100
delay: 5

- name: Install ansible dependencies
ansible.builtin.pip:
requirements: https://raw.githubusercontent.com/openstack-k8s-operators/ci-framework/main/common-requirements.txt

- name: Inject most of the cifmw_ parameters passed to the reproducer run
tags:
- bootstrap_env
vars:
_filtered_vars: >-
{{
Expand Down
13 changes: 10 additions & 3 deletions roles/reproducer/tasks/libvirt_layout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
tags:
- bootstrap
- bootstrap_layout
ansible.builtin.import_tasks: configure_controller.yml
- bootstrap_env
ansible.builtin.include_tasks: configure_controller.yml

- name: Configure CRC node if available
when:
Expand All @@ -82,7 +83,12 @@
tags:
- bootstrap
- bootstrap_layout
ansible.builtin.import_tasks: configure_crc.yml
ansible.builtin.include_tasks:
file: configure_crc.yml
apply:
tags:
- boostrap
- bootstrap_layout

# We have to configure the compute ctlplane interface.
# In order to do this, we'll consume the generated networking_mapper
Expand All @@ -103,7 +109,8 @@
_controller_ip4: "{{ cifmw_networking_env_definition.instances['controller-0'].networks.ctlplane.ip_v4 }}"
_prefix: "{{cifmw_networking_env_definition.networks.ctlplane.network_v4 | ansible.utils.ipaddr('prefix') }}"
ansible.builtin.include_tasks: configure_computes.yml
loop: "{{ cifmw_networking_env_definition.instances | dict2items }}"
loop: >-
{{ cifmw_networking_env_definition.instances | dict2items }}
loop_control:
loop_var: compute
label: "{{ compute.key }}"
37 changes: 33 additions & 4 deletions roles/reproducer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@
- name: Bootstrap libvirt if needed
when:
- cifmw_use_libvirt | default(false) | bool
tags:
- bootstrap_libvirt
ansible.builtin.include_role:
name: libvirt_manager
apply:
tags:
- bootstrap_libvirt

- name: Deploy CRC if needed
when:
Expand All @@ -76,7 +81,13 @@
- bootstrap
- bootstrap_layout
- crc_layout
ansible.builtin.include_tasks: crc_layout.yml
ansible.builtin.include_tasks:
file: crc_layout.yml
apply:
tags:
- bootstrap
- bootstrap_layout
- crc_layout

- name: Consume dev-scripts for OCP cluster
when:
Expand All @@ -89,15 +100,27 @@
tags:
- bootstrap
- boostrap_layout
ansible.builtin.include_tasks: devscripts_layout.yml
- libvirt_layout
ansible.builtin.include_tasks:
file: devscripts_layout.yml
apply:
tags:
- bootstrap
- bootstrap_layout

- name: Consume libvirt_manager
when:
- cifmw_use_libvirt | default(false) | bool
tags:
- bootstrap
- bootstrap_layout
ansible.builtin.include_tasks: libvirt_layout.yml
- bootstrap_env
ansible.builtin.include_tasks:
file: libvirt_layout.yml
apply:
tags:
- bootstrap
- bootstrap_layout

- name: Apply VLAN ids to TAP type interfaces.
when:
Expand Down Expand Up @@ -161,7 +184,13 @@
- name: Prepare VA deployment
when:
- cifmw_architecture_scenario is defined
ansible.builtin.include_tasks: configure_architecture.yml
tags:
- deploy_architecture
ansible.builtin.include_tasks:
file: configure_architecture.yml
apply:
tags:
- deploy_architecture

- name: Prepare ci-like EDPM deploy
delegate_to: controller-0
Expand Down

0 comments on commit 9f2ace7

Please sign in to comment.