Skip to content

Commit 4b40434

Browse files
drosenfeopenshift-merge-bot[bot]
authored andcommitted
[validations] Restore original image after hotfix
Restore original image after simulated hotfix test. This leaves compute nodes in a known state and prevents failures in subsequent tests. Signed-off-by: David Rosenfeld <drosenfe@redhat.com>
1 parent d4ae12d commit 4b40434

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

roles/validations/tasks/edpm/hotfix.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
oc get osdpns -n {{ cifmw_validations_namespace }} --no-headers -o custom-columns=":metadata.name"
1717
register: deployed_nodeset_name
1818

19+
# Collect running image before the hotfix is applied
20+
- name: Collect the image currently used by nova_compute on the edpm node
21+
become: true
22+
ansible.builtin.shell:
23+
cmd: >-
24+
set -o pipefail && podman inspect nova_compute | jq '.[].ImageName' | tr -d '"'
25+
delegate_to: "{{ cifmw_validations_edpm_check_node }}"
26+
register: original_nova_compute_image
27+
1928
# Simulate hotfixed image by update edpm_nova_compute_image to a different, non-default value
2029
- name: Update edpm_nova_compute_image value
2130
environment:
@@ -90,6 +99,83 @@
9099
that:
91100
- cifmw_validations_hotfixed_edpm_nova_compute_image == post_change_nova_compute_image.stdout
92101

102+
# Restore hot fixed image to original value
103+
- name: Update edpm_nova_compute_image value
104+
environment:
105+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
106+
PATH: "{{ cifmw_path }}"
107+
cifmw.general.ci_script:
108+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
109+
script: >-
110+
oc patch -n {{ cifmw_validations_namespace }}
111+
osdpns/"{{ deployed_nodeset_name.stdout | trim }}"
112+
--type=merge -p '{"spec": {"nodeTemplate": {"ansible": {"ansibleVars": {"edpm_nova_compute_image": "{{ original_nova_compute_image.stdout }}"}}}}}'
113+
114+
# loop check the status of the openstackdataplanenodeset until it is either SetupReady,
115+
# or reaches a defined timeout value.
116+
- name: Wait for nodeset to be SetupReady again
117+
environment:
118+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
119+
PATH: "{{ cifmw_path }}"
120+
cifmw.general.ci_script:
121+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
122+
script: >-
123+
oc wait osdpns "{{ deployed_nodeset_name.stdout | trim }}"
124+
--namespace={{ cifmw_validations_namespace }}
125+
--for=condition=SetupReady
126+
--timeout={{ cifmw_validations_timeout }}m
127+
128+
# Create a new OpenStackDataPlaneDeployment to restore the original image
129+
- name: Create openstackdataplanedeployment to rollout changes
130+
environment:
131+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
132+
PATH: "{{ cifmw_path }}"
133+
cifmw.general.ci_script:
134+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
135+
script: |
136+
oc apply -f - <<EOF
137+
apiVersion: dataplane.openstack.org/v1beta1
138+
kind: OpenStackDataPlaneDeployment
139+
metadata:
140+
name: remove-edpm-hotfix
141+
namespace: {{ cifmw_validations_namespace }}
142+
spec:
143+
nodeSets:
144+
- "{{ deployed_nodeset_name.stdout | trim }}"
145+
servicesOverride:
146+
- "{{ cifmw_validations_custom_nova_service }}"
147+
EOF
148+
149+
# loop check the status of the openstackdataplanedeployment until it is either completed,
150+
# or reaches a defined timeout value.
151+
- name: Wait for deployment to be complete
152+
environment:
153+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
154+
PATH: "{{ cifmw_path }}"
155+
cifmw.general.ci_script:
156+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
157+
script: >-
158+
oc wait openstackdataplanedeployment remove-edpm-hotfix
159+
--namespace={{ cifmw_validations_namespace }}
160+
--for=condition=ready
161+
--timeout={{ cifmw_validations_timeout }}m
162+
163+
# Collect running image to assert the hotfix was removed
164+
- name: Collect the image currently used by nova_compute on the edpm node
165+
become: true
166+
ansible.builtin.shell:
167+
cmd: >-
168+
set -o pipefail && podman inspect nova_compute | jq '.[].ImageName' | tr -d '"'
169+
delegate_to: "{{ cifmw_validations_edpm_check_node }}"
170+
register: post_remove_nova_compute_image
171+
172+
# these assertions will determine whether this job has ultimately been successful or not.
173+
# here, we should list all of the assertions required to satisfy our feature requirements.
174+
- name: Assert state change reflects our requirements
175+
ansible.builtin.assert:
176+
that:
177+
- original_nova_compute_image.stdout == post_remove_nova_compute_image.stdout
178+
93179
- name: Wait for all nova-compute services to be up after hotfix rollout
94180
cifmw.general.ci_script:
95181
output_dir: "{{ cifmw_validations_basedir }}/artifacts"

0 commit comments

Comments
 (0)