zuul-jobs/roles/test-prepare-workspace-git/tasks/main.yaml
James E. Blair f1714ea75b Update test-prepare-workspace-git to use a module
This updates test-prepare-workspace-git to use a new Ansible module
for its work.  This module supports each of the three main tasks
with a single Python invocation for all projects, rather than
using Ansible to loop over them.

Within the python invocation, a ThreadPoolExecutor with 10 workers
is used to execute the setup processes with increased parallelism.

This should greatly improve the workspace sync speed for jobs with
large numbers of repos.

A simple local test with the 16 Zuul project repos reduces the
workspace-prep time to less than 50% of the current time.

This removes the mirror_workspace_quiet role variable, since detailed
information about the repo state can now be found in the repo state
JSON file.

Otherwise, the actual git commands used to prepare the repos should
be identical.

Change-Id: Ib4b6bb379fe656ac9109b8e6073eff8c28c7eaee
2024-08-02 11:47:37 -07:00

42 lines
1.5 KiB
YAML

- name: Filter zuul projects if sync-only-required-projects flag is set
set_fact:
_zuul_projects: >
{{ _zuul_projects | default({}) |
combine({ zj_project.key : zj_project.value }) }}
with_dict: "{{ zuul.projects }}"
loop_control:
loop_var: zj_project
when:
- prepare_workspace_sync_required_projects_only
- zj_project.value.canonical_name == zuul.project.canonical_name or zj_project.value.required
- name: Don't filter zuul projects if flag is false
set_fact:
_zuul_projects: "{{ zuul.projects }}"
when: not prepare_workspace_sync_required_projects_only
- name: Set initial repo states in workspace
repo_prep:
cached_repos_root: "{{ cached_repos_root }}"
executor_work_root: "{{ zuul.executor.work_root }}"
zuul_projects: "{{ _zuul_projects }}"
zuul_workspace_root: "{{ zuul_workspace_root }}"
- name: Synchronize src repos to workspace directory
delegate_to: localhost
repo_sync:
ansible_connection: "{{ ansible_connection }}"
ansible_host: "{{ ansible_host | ansible.utils.ipwrap }}"
ansible_port: "{{ ansible_port }}"
ansible_user: "{{ ansible_user }}"
executor_work_root: "{{ zuul.executor.work_root }}"
inventory_hostname: "{{ inventory_hostname }}"
zuul_projects: "{{ _zuul_projects }}"
zuul_resources: "{{ zuul.resources | default({}) }}"
zuul_workspace_root: "{{ zuul_workspace_root }}"
- name: Update remote repository state
repo_update:
zuul_projects: "{{ _zuul_projects }}"
zuul_workspace_root: "{{ zuul_workspace_root }}"