Skip to content

Commit 25c8dcf

Browse files
author
David Sariel
committed
[openshift_setup] pre-pull RBAC proxy images on master nodes
When digest mirrors are configured, optionally pre-pull any RBAC proxy images found in the mirror list on all master nodes. This avoids pull failures at workload deployment time when the cluster cannot reach the original registry directly. The feature is controlled by cifmw_openshift_setup_prepull_rbac_images (default: true) and is skipped when no digest mirrors are defined or when no mirrors match the RBAC proxy image pattern. Each image is pulled via `oc debug node` using the node's existing kubelet auth credentials. Failures are non-fatal and a summary of successful pulls is logged at the end. Signed-off-by: David Sariel <dsariel@redhat.com> ANVIL-142
1 parent 2d92bae commit 25c8dcf

2 files changed

Lines changed: 150 additions & 82 deletions

File tree

roles/openshift_setup/tasks/configure_registries.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,71 @@
7171
name: registry-tag-mirrors
7272
spec:
7373
imageTagMirrors: "{{ cifmw_openshift_setup_tag_mirrors }}"
74+
75+
- name: Pre-pull RBAC proxy images on all master nodes
76+
when:
77+
- cifmw_openshift_setup_digest_mirrors is defined
78+
- cifmw_openshift_setup_digest_mirrors | length > 0
79+
- cifmw_openshift_setup_prepull_rbac_images | default(true) | bool
80+
block:
81+
- name: Extract RBAC proxy images from digest mirrors
82+
ansible.builtin.set_fact:
83+
_rbac_proxy_images: >-
84+
{{
85+
cifmw_openshift_setup_digest_mirrors
86+
| map(attribute='mirrors')
87+
| flatten
88+
| select('match', '^image-rbac.*\\.com/.*')
89+
| list
90+
}}
91+
92+
- name: Extract RBAC proxy images from digest mirrors
93+
ansible.builtin.set_fact:
94+
_rbac_proxy_images: >-
95+
{{
96+
cifmw_openshift_setup_digest_mirrors
97+
| map(attribute='mirrors')
98+
| flatten
99+
| select('match', '^image-rbac.*\\.com/.*')
100+
| list
101+
}}
102+
103+
- name: Debug all flattened mirrors and matched result
104+
ansible.builtin.debug:
105+
msg:
106+
- "All mirrors: {{ cifmw_openshift_setup_digest_mirrors | map(attribute='mirrors') | flatten | list }}"
107+
- "Matched RBAC: {{ _rbac_proxy_images }}"
108+
109+
- name: Get list of master nodes
110+
kubernetes.core.k8s_info:
111+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
112+
api_key: "{{ cifmw_openshift_token | default(omit)}}"
113+
context: "{{ cifmw_openshift_context | default(omit)}}"
114+
kind: Node
115+
label_selectors:
116+
- node-role.kubernetes.io/master
117+
register: _master_nodes_info
118+
119+
- name: Set master node names list
120+
ansible.builtin.set_fact:
121+
_master_node_names: "{{ _master_nodes_info.resources | map(attribute='metadata.name') | list }}"
122+
123+
- name: Pre-pull RBAC proxy images on each master node
124+
ansible.builtin.shell: |
125+
oc debug node/{{ item.0 }} -- \
126+
chroot /host podman pull --authfile /var/lib/kubelet/config.json {{ item.1 }}
127+
environment:
128+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
129+
loop: "{{ _master_node_names | product(_rbac_proxy_images) | list }}"
130+
loop_control:
131+
label: "{{ item.0 }}: {{ item.1 | basename }}"
132+
failed_when: false
133+
changed_when: true
134+
register: _prepull_results
135+
136+
- name: Display pre-pull summary
137+
ansible.builtin.debug:
138+
msg: >-
139+
Pre-pulled {{ _prepull_results.results | selectattr('rc', 'equalto', 0) | list | length }}
140+
/ {{ _prepull_results.results | length }} RBAC proxy images
141+
({{ _master_node_names | length }} masters × {{ _rbac_proxy_images | length }} images)

roles/reproducer/tasks/main.yml

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -451,85 +451,85 @@
451451
name: openshift_setup
452452
tasks_from: patch_network_operator.yml
453453

454-
# Run from the hypervisor
455-
- name: Ensure OCP cluster is stable
456-
when:
457-
- _wait_ocp_cluster is defined
458-
- _wait_ocp_cluster | bool
459-
tags:
460-
- bootstrap
461-
- bootstrap_layout
462-
vars:
463-
_auth_path: >-
464-
{{
465-
(
466-
cifmw_devscripts_repo_dir | default(
467-
ansible_user_dir ~ '/src/github.com/openshift-metal3/dev-scripts'),
468-
'ocp',
469-
cifmw_bm_agent_cluster_name |
470-
default(cifmw_devscripts_config.cluster_name | default('ocp')),
471-
'auth'
472-
) | ansible.builtin.path_join
473-
}}
474-
cifmw_openshift_adm_op: "stable"
475-
cifmw_openshift_kubeconfig: >-
476-
{{ (_auth_path, 'kubeconfig') | ansible.builtin.path_join }}
477-
ansible.builtin.include_role:
478-
name: openshift_adm
479-
480-
- name: Run from controller-0
481-
when:
482-
- _has_openshift
483-
- (
484-
_cifmw_libvirt_manager_layout.vms.controller.target is defined and
485-
_cifmw_libvirt_manager_layout.vms.controller.target == inventory_hostname
486-
) or
487-
_cifmw_libvirt_manager_layout.vms.controller.target is undefined
488-
delegate_to: controller-0
489-
block:
490-
- name: Emulate CI job
491-
when:
492-
- cifmw_job_uri is defined
493-
ansible.builtin.include_tasks: ci_job.yml
494-
495-
- name: Prepare architecture-based deployment
496-
when:
497-
- cifmw_architecture_scenario is defined
498-
- cifmw_job_uri is undefined
499-
tags:
500-
- deploy_architecture
501-
ansible.builtin.include_tasks:
502-
file: configure_architecture.yml
503-
apply:
504-
tags:
505-
- deploy_architecture
506-
507-
- name: Prepare architecture-based post deployment
508-
when:
509-
- cifmw_architecture_scenario is defined
510-
- cifmw_job_uri is undefined
511-
tags:
512-
- deploy_architecture
513-
ansible.builtin.include_tasks:
514-
file: configure_post_deployment.yml
515-
516-
- name: Prepare ci-like EDPM deploy
517-
when:
518-
- cifmw_job_uri is undefined
519-
delegate_to: controller-0
520-
vars:
521-
run_directory: "{{ _cifmw_reproducer_framework_location }}"
522-
exports:
523-
ANSIBLE_LOG_PATH: "~/ansible-deploy-edpm.log"
524-
default_extravars:
525-
- "@scenarios/centos-9/base.yml"
526-
- "@scenarios/centos-9/edpm_ci.yml"
527-
- "cifmw_openshift_password='{{ cifmw_openshift_password }}'"
528-
extravars: "{{ cifmw_reproducer_play_extravars }}"
529-
playbook: "deploy-edpm.yml"
530-
ansible.builtin.template:
531-
dest: "{{ cifmw_reproducer_controller_user_dir }}/deploy-edpm.sh"
532-
src: "script.sh.j2"
533-
mode: "0755"
534-
owner: "{{ cifmw_reproducer_controller_user }}"
535-
group: "{{ cifmw_reproducer_controller_user }}"
454+
# # Run from the hypervisor
455+
# - name: Ensure OCP cluster is stable
456+
# when:
457+
# - _wait_ocp_cluster is defined
458+
# - _wait_ocp_cluster | bool
459+
# tags:
460+
# - bootstrap
461+
# - bootstrap_layout
462+
# vars:
463+
# _auth_path: >-
464+
# {{
465+
# (
466+
# cifmw_devscripts_repo_dir | default(
467+
# ansible_user_dir ~ '/src/github.com/openshift-metal3/dev-scripts'),
468+
# 'ocp',
469+
# cifmw_bm_agent_cluster_name |
470+
# default(cifmw_devscripts_config.cluster_name | default('ocp')),
471+
# 'auth'
472+
# ) | ansible.builtin.path_join
473+
# }}
474+
# cifmw_openshift_adm_op: "stable"
475+
# cifmw_openshift_kubeconfig: >-
476+
# {{ (_auth_path, 'kubeconfig') | ansible.builtin.path_join }}
477+
# ansible.builtin.include_role:
478+
# name: openshift_adm
479+
480+
# - name: Run from controller-0
481+
# when:
482+
# - _has_openshift
483+
# - (
484+
# _cifmw_libvirt_manager_layout.vms.controller.target is defined and
485+
# _cifmw_libvirt_manager_layout.vms.controller.target == inventory_hostname
486+
# ) or
487+
# _cifmw_libvirt_manager_layout.vms.controller.target is undefined
488+
# delegate_to: controller-0
489+
# block:
490+
# - name: Emulate CI job
491+
# when:
492+
# - cifmw_job_uri is defined
493+
# ansible.builtin.include_tasks: ci_job.yml
494+
495+
# - name: Prepare architecture-based deployment
496+
# when:
497+
# - cifmw_architecture_scenario is defined
498+
# - cifmw_job_uri is undefined
499+
# tags:
500+
# - deploy_architecture
501+
# ansible.builtin.include_tasks:
502+
# file: configure_architecture.yml
503+
# apply:
504+
# tags:
505+
# - deploy_architecture
506+
507+
# - name: Prepare architecture-based post deployment
508+
# when:
509+
# - cifmw_architecture_scenario is defined
510+
# - cifmw_job_uri is undefined
511+
# tags:
512+
# - deploy_architecture
513+
# ansible.builtin.include_tasks:
514+
# file: configure_post_deployment.yml
515+
516+
# - name: Prepare ci-like EDPM deploy
517+
# when:
518+
# - cifmw_job_uri is undefined
519+
# delegate_to: controller-0
520+
# vars:
521+
# run_directory: "{{ _cifmw_reproducer_framework_location }}"
522+
# exports:
523+
# ANSIBLE_LOG_PATH: "~/ansible-deploy-edpm.log"
524+
# default_extravars:
525+
# - "@scenarios/centos-9/base.yml"
526+
# - "@scenarios/centos-9/edpm_ci.yml"
527+
# - "cifmw_openshift_password='{{ cifmw_openshift_password }}'"
528+
# extravars: "{{ cifmw_reproducer_play_extravars }}"
529+
# playbook: "deploy-edpm.yml"
530+
# ansible.builtin.template:
531+
# dest: "{{ cifmw_reproducer_controller_user_dir }}/deploy-edpm.sh"
532+
# src: "script.sh.j2"
533+
# mode: "0755"
534+
# owner: "{{ cifmw_reproducer_controller_user }}"
535+
# group: "{{ cifmw_reproducer_controller_user }}"

0 commit comments

Comments
 (0)