Skip to content

Commit 692d36c

Browse files
committed
[edpm_prepare] Add new job to run minor update with baremetal deployment
Adds a new baremetal job to test minor update with upstream github content. This will currently test from fr3->main(with PR). Signed-off-by: rabi <ramishra@redhat.com>
1 parent 84c46b6 commit 692d36c

File tree

6 files changed

+450
-3
lines changed

6 files changed

+450
-3
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
- name: "Run ci/playbooks/edpm_baremetal_update/run.yml"
3+
hosts: "{{ cifmw_zuul_target_host | default('all') }}"
4+
gather_facts: true
5+
tasks:
6+
- name: Filter out host if needed
7+
when:
8+
- cifmw_zuul_target_host is defined
9+
- cifmw_zuul_target_host != 'all'
10+
- inventory_hostname != cifmw_zuul_target_host
11+
ansible.builtin.meta: end_host
12+
13+
- name: Check for edpm-ansible.yml file
14+
ansible.builtin.stat:
15+
path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml"
16+
register: edpm_file
17+
18+
- name: Check if new ssh keypair exists
19+
ansible.builtin.include_role:
20+
name: recognize_ssh_keypair
21+
22+
- name: Add crc node in local inventory
23+
ansible.builtin.add_host:
24+
name: crc
25+
ansible_ssh_private_key_file: "{{ ansible_user_dir }}/.crc/machines/crc/{{ crc_ssh_keypair }}"
26+
ansible_ssh_user: core
27+
ansible_host: api.crc.testing
28+
29+
- name: Ensure we know ssh hosts
30+
ansible.builtin.shell:
31+
cmd: "ssh-keyscan {{ hostvars[item].ansible_host }} >> ~/.ssh/known_hosts"
32+
loop: "{{ hostvars.keys() | reject('equalto', 'localhost') }}"
33+
34+
- name: Inject CRC in zuul_inventory
35+
block:
36+
- name: Load zuul_inventory
37+
register: _inventory
38+
ansible.builtin.slurp:
39+
path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
40+
41+
- name: Inject CRC in zuul_inventory.yml
42+
vars:
43+
_crc:
44+
all:
45+
hosts:
46+
crc: "{{ dict(hostvars.crc) }}"
47+
_updated: >-
48+
{{
49+
_inventory.content | b64decode | from_yaml | combine(_crc, recursive=true)
50+
}}
51+
ansible.builtin.copy:
52+
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
53+
content: "{{ _updated | to_nice_yaml }}"
54+
mode: "0644"
55+
56+
- name: Set default pre-update tag if not provided
57+
ansible.builtin.set_fact:
58+
cifmw_minor_update_pre_update_tag: "{{ cifmw_minor_update_pre_update_tag | default('18.0-fr3-latest') }}"
59+
60+
- name: Get pre-update index image digest from tag
61+
ansible.builtin.shell: >-
62+
skopeo inspect
63+
docker://quay.io/openstack-k8s-operators/openstack-operator-index:{{ cifmw_minor_update_pre_update_tag }}
64+
| jq -r '.Digest'
65+
register: pre_update_digest_result
66+
changed_when: false
67+
failed_when: pre_update_digest_result.rc != 0
68+
69+
- name: Set pre-update index image using digest from tag
70+
ansible.builtin.set_fact:
71+
cifmw_minor_update_pre_update_index_image: >-
72+
quay.io/openstack-k8s-operators/openstack-operator-index@{{ pre_update_digest_result.stdout | trim }}
73+
74+
- name: Get minor update index image from content provider or use default
75+
ansible.builtin.set_fact:
76+
cifmw_minor_update_index_image: >-
77+
{{
78+
cifmw_operator_build_output.operators['openstack-operator'].image_catalog
79+
if (cifmw_operator_build_output is defined and
80+
cifmw_operator_build_output.operators is defined and
81+
'openstack-operator' in cifmw_operator_build_output.operators)
82+
else cifmw_minor_update_pre_update_index_image
83+
}}
84+
85+
- name: Override operator build output with pre-update index image for Phase 1
86+
ansible.builtin.set_fact:
87+
cifmw_operator_build_output_pre_update: >-
88+
{{
89+
{
90+
'cifmw_operator_build_output': {
91+
'operators': {
92+
'openstack-operator': {
93+
'image_catalog': cifmw_minor_update_pre_update_index_image
94+
}
95+
}
96+
}
97+
}
98+
}}
99+
100+
- name: Phase 1 - Deploy with pre-update index image using deploy-edpm.yml
101+
block:
102+
- name: Write pre-update operator build output to temporary file
103+
ansible.builtin.copy:
104+
dest: "{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_pre_update.yml"
105+
content: "{{ cifmw_operator_build_output_pre_update | to_nice_yaml }}"
106+
mode: "0644"
107+
108+
- name: Perform Podified and EDPM deployment on compute nodes with virtual baremetal (pre-update)
109+
ansible.builtin.command:
110+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
111+
cmd: >-
112+
ansible-playbook deploy-edpm.yml
113+
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
114+
-e @group_vars/all.yml
115+
-e @scenarios/centos-9/base.yml
116+
-e @scenarios/centos-9/edpm_baremetal_deployment_ci.yml
117+
{%- if edpm_file.stat.exists %}
118+
-e @{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml
119+
{%- endif %}
120+
{%- if cifmw_extras is defined %}
121+
{%- for extra_var in cifmw_extras %}
122+
-e "{{ extra_var }}"
123+
{%- endfor %}
124+
{%- endif %}
125+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
126+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/operator_build_output_pre_update.yml"
127+
-e "cifmw_prepare_openstackversion=false"
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
---
2+
# CI playbook for OpenStack minor version updates.
3+
# This playbook performs a minor version update of an OpenStack deployment
4+
# using index images and install_yamls make targets.
5+
# This playbook depends on content provider variables from CI jobs.
6+
# It runs on cifmw_target_host in the same execution context as deploy-edpm.yml,
7+
# so it can use the install_yamls_makes role that was generated during bootstrap.
8+
9+
- name: OpenStack minor version update
10+
hosts: "{{ cifmw_target_host | default('localhost') }}"
11+
gather_facts: false
12+
tasks:
13+
- name: Set cifmw_basedir if not defined
14+
ansible.builtin.set_fact:
15+
cifmw_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}"
16+
17+
- name: Set update artifacts basedir if not defined
18+
ansible.builtin.set_fact:
19+
cifmw_update_artifacts_basedir: "{{ cifmw_update_artifacts_basedir | default(cifmw_basedir ~ '/tests/update') }}"
20+
21+
- name: Initialize monitoring
22+
ansible.builtin.include_role:
23+
name: update
24+
tasks_from: init_monitoring.yml
25+
26+
- name: Load parameters files
27+
ansible.builtin.include_vars:
28+
dir: "{{ cifmw_basedir }}/artifacts/parameters"
29+
30+
- name: Set install_yamls environment for minor update phase
31+
ansible.builtin.set_fact:
32+
cifmw_minor_update_env: >-
33+
{{
34+
(cifmw_install_yamls_environment | default({})) |
35+
combine({'PATH': cifmw_path | default(ansible_user_dir ~ '/.crc/bin:' ~ ansible_user_dir ~ '/.crc/bin/oc:' ~ ansible_user_dir ~ '/bin:' ~ ansible_env.PATH)}) |
36+
combine({'OPENSTACK_IMG': cifmw_minor_update_index_image}) |
37+
combine({'BMO_CLEANUP': false})
38+
}}
39+
40+
- name: Set update step to Running openstack cleanup
41+
ansible.builtin.command:
42+
cmd: >
43+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
44+
Running openstack cleanup
45+
46+
- name: Run make openstack_cleanup
47+
vars:
48+
make_openstack_cleanup_env: "{{ cifmw_minor_update_env }}"
49+
make_openstack_cleanup_dryrun: false
50+
ansible.builtin.include_role:
51+
name: 'install_yamls_makes'
52+
tasks_from: 'make_openstack_cleanup'
53+
ignore_errors: true # Continue even if cleanup fails
54+
55+
- name: Set update step to Running openstack wait
56+
ansible.builtin.command:
57+
cmd: >
58+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
59+
Running openstack wait
60+
61+
- name: Run make openstack_wait (minor update)
62+
vars:
63+
make_openstack_wait_env: "{{ cifmw_minor_update_env }}"
64+
make_openstack_wait_dryrun: false
65+
ansible.builtin.include_role:
66+
name: 'install_yamls_makes'
67+
tasks_from: 'make_openstack_wait'
68+
69+
- name: Set update step to Running openstack init
70+
ansible.builtin.command:
71+
cmd: >
72+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
73+
Running openstack init
74+
75+
- name: Run make openstack_init (minor update)
76+
vars:
77+
make_openstack_init_env: "{{ cifmw_minor_update_env }}"
78+
make_openstack_init_dryrun: false
79+
ansible.builtin.include_role:
80+
name: 'install_yamls_makes'
81+
tasks_from: 'make_openstack_init'
82+
83+
- name: Set update step to Waiting for new version to be available
84+
ansible.builtin.command:
85+
cmd: >
86+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
87+
Waiting for new version to be available
88+
89+
- name: Wait for availableVersion to be different from deployedVersion
90+
kubernetes.core.k8s_info:
91+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
92+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
93+
context: "{{ cifmw_openshift_context | default(omit) }}"
94+
api_version: core.openstack.org/v1beta1
95+
kind: OpenStackVersion
96+
namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}"
97+
register: openstackversion_wait_info
98+
retries: 10
99+
delay: 60
100+
until: >
101+
openstackversion_wait_info.resources is defined and
102+
openstackversion_wait_info.resources | length > 0 and
103+
openstackversion_wait_info.resources[0].status.availableVersion is defined and
104+
openstackversion_wait_info.resources[0].status.deployedVersion is defined and
105+
openstackversion_wait_info.resources[0].status.availableVersion != openstackversion_wait_info.resources[0].status.deployedVersion
106+
107+
- name: Get available version from OpenStackVersion CR
108+
ansible.builtin.set_fact:
109+
cifmw_minor_update_target_version: "{{ openstackversion_wait_info.resources[0].status.availableVersion }}"
110+
111+
- name: Set update step to Patching OpenStackVersion CR
112+
ansible.builtin.command:
113+
cmd: >
114+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
115+
Patching OpenStackVersion CR with version {{ cifmw_minor_update_target_version }}
116+
117+
- name: Patch OpenStackVersion CR availableVersion
118+
vars:
119+
make_openstack_patch_version_env: "{{ cifmw_minor_update_env }}"
120+
make_openstack_patch_version_dryrun: false
121+
ansible.builtin.include_role:
122+
name: 'install_yamls_makes'
123+
tasks_from: 'make_openstack_patch_version'
124+
125+
- name: Set vars related to update_containers content provider
126+
when:
127+
- content_provider_os_registry_url is defined
128+
- content_provider_os_registry_url != 'null'
129+
ansible.builtin.set_fact:
130+
cifmw_update_containers_registry: "{{ content_provider_os_registry_url | split('/') | first }}"
131+
cifmw_update_containers_org: "{{ content_provider_os_registry_url | split('/') | last }}"
132+
cifmw_update_containers_tag: "{{ content_provider_dlrn_md5_hash }}"
133+
cifmw_update_containers_openstack: true
134+
135+
- name: Set update step to Updating container images
136+
when: >-
137+
(cifmw_update_containers_edpm_image_url is defined and
138+
cifmw_update_containers_openstack is defined and
139+
cifmw_update_containers_openstack | bool) or
140+
(cifmw_update_containers_ansibleee_image_url is defined) or
141+
(cifmw_update_containers_openstack is defined and
142+
cifmw_update_containers_openstack | bool) or
143+
(cifmw_update_containers_watcher is defined and
144+
cifmw_update_containers_watcher | bool)
145+
ansible.builtin.command:
146+
cmd: >
147+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
148+
Updating container images
149+
150+
- name: Prepare and patch OpenStackVersion CR for update
151+
vars:
152+
cifmw_update_containers_metadata: "controlplane"
153+
cifmw_update_containers: true
154+
ansible.builtin.include_role:
155+
name: update_containers
156+
when: >-
157+
(cifmw_update_containers_edpm_image_url is defined and
158+
cifmw_update_containers_openstack is defined and
159+
cifmw_update_containers_openstack | bool) or
160+
(cifmw_update_containers_ansibleee_image_url is defined) or
161+
(cifmw_update_containers_openstack is defined and
162+
cifmw_update_containers_openstack | bool) or
163+
( cifmw_update_containers_watcher is defined and
164+
cifmw_update_containers_watcher | bool)
165+
166+
- name: Set update step to Starting the CI update sequence
167+
ansible.builtin.command:
168+
cmd: >
169+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
170+
Starting the CI update sequence
171+
172+
- name: Run make openstack_update_run
173+
vars:
174+
make_openstack_update_run_env: "{{ cifmw_minor_update_env }}"
175+
make_openstack_update_run_params:
176+
OPENSTACK_VERSION: "{{ cifmw_minor_update_target_version }}"
177+
make_openstack_update_run_dryrun: false
178+
ansible.builtin.include_role:
179+
name: 'install_yamls_makes'
180+
tasks_from: 'make_openstack_update_run'
181+
182+
- name: Set update step to Verifying update completion
183+
ansible.builtin.command:
184+
cmd: >
185+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
186+
Verifying update completion
187+
188+
- name: Verify deployed version matches target version
189+
kubernetes.core.k8s_info:
190+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
191+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
192+
context: "{{ cifmw_openshift_context | default(omit) }}"
193+
api_version: core.openstack.org/v1beta1
194+
kind: OpenStackVersion
195+
namespace: "{{ cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') }}"
196+
register: openstackversion_verify_info
197+
until: >
198+
openstackversion_verify_info.resources is defined and
199+
openstackversion_verify_info.resources | length > 0 and
200+
openstackversion_verify_info.resources[0].status.deployedVersion is defined and
201+
openstackversion_verify_info.resources[0].status.deployedVersion == cifmw_minor_update_target_version
202+
retries: 5
203+
delay: 2
204+
205+
- name: Set update step to CI update sequence complete
206+
ansible.builtin.command:
207+
cmd: >
208+
{{ cifmw_update_artifacts_basedir }}/update_event.sh
209+
CI update verification successful - Target version {{ cifmw_minor_update_target_version }}
210+
matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }}
211+
212+
- name: Display update verification result
213+
ansible.builtin.debug:
214+
msg: >-
215+
Update verification successful: Target version {{ cifmw_minor_update_target_version }}
216+
matches deployed version {{ openstackversion_verify_info.resources[0].status.deployedVersion }}
217+
218+
- name: Stop monitoring
219+
block:
220+
- name: Verify monitoring pid file
221+
ansible.builtin.stat:
222+
path: "{{ cifmw_update_artifacts_basedir }}/monitor_resources_changes.pid"
223+
register: cifmw_update_monitoring_pid
224+
225+
- name: Stop the monitoring process
226+
ansible.builtin.shell:
227+
cmd: >-
228+
kill
229+
$(cat {{ cifmw_update_artifacts_basedir }}/monitor_resources_changes.pid)
230+
register: _kill_result
231+
failed_when: _kill_result.rc not in [0, 1]
232+
when: cifmw_update_monitoring_pid.stat.exists | bool
233+
234+
- name: Run post_update hooks
235+
vars:
236+
step: post_update
237+
ansible.builtin.import_role:
238+
name: run_hook
239+
240+
- name: Run cifmw_setup run_tests.yml
241+
when: cifmw_run_tests | default(false) | bool
242+
vars:
243+
cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir|default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator_update"
244+
cifmw_test_operator_tempest_name: "post-update-tempest-tests"
245+
ansible.builtin.import_role:
246+
name: cifmw_setup
247+
tasks_from: run_tests.yml
248+
tags:
249+
- run-tests

0 commit comments

Comments
 (0)