Skip to content

Commit b2ab112

Browse files
committed
[shiftstack] Use GitHub for shiftstack-qa clone and fix false-positive test results
shiftstack-qa moved code review to GitHub PRs (shiftstack/ shiftstack-qa#2). The role default still clones from GerritHub, which is no longer maintained. - Change cifmw_shiftstack_qa_repo default to GitHub - Rename cifmw_shiftstack_qa_gerrithub_change to cifmw_shiftstack_qa_change_ref Also fix a false-positive bug in exec_command_in_pod.yml where oc rsh could return rc=0 before the inner command finished, causing the test to report PASS when the playbook actually failed. Observed in tp!2297 build d078ccbd - the shiftstack test ran for only 145s (vs typical 1.5-2h), OCP was never installed, yet the job reported SUCCESS. The fix writes the inner command exit code to a marker file on the pod, then verifies it in a separate oc exec call. This catches failures even if the first oc exec connection drops mid-execution. Also switches from oc rsh to oc exec for non-interactive pod commands. Related-Issue: #OSPRH-29506 Assisted-By: Claude Code Signed-off-by: Itay Matza <imatza@redhat.com>
1 parent 68c9a19 commit b2ab112

4 files changed

Lines changed: 52 additions & 13 deletions

File tree

roles/shiftstack/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Role for triggering Openshift on Openstack QA automation (installation and tests
1919
* `cifmw_shiftstack_manifests_dir`: (*string*) Directory name for the role generated Openshift manifests. Defaults to `"{{ cifmw_shiftstack_basedir }}/manifests"`.
2020
* `cifmw_shiftstack_project_name`: (*string*) The Openstack project name. Defaults to `shiftstack`.
2121
* `cifmw_shiftstack_proxy`: (*string*) The proxy url that should be used to reach the underlying OCP. Defaults to omit.
22-
* `cifmw_shiftstack_qa_gerrithub_change`: (*string*) The gerrithub change to fetch from the `cifmw_shiftstack_qa_repo` repository (i.e. 'refs/changes/29/1188429/50)'. Defaults to ''.
23-
* `cifmw_shiftstack_qa_repo`: (*string*) The repository containing the Openshift on Openstack QA automation. Defaults to `https://review.gerrithub.io/shiftstack/shiftstack-qa`.
22+
* `cifmw_shiftstack_qa_change_ref`: (*string*) A git ref to fetch and checkout from the `cifmw_shiftstack_qa_repo` repository. Supports GitHub PR refs (e.g. `refs/pull/5/head`) and GerritHub change refs (e.g. `refs/changes/29/1188429/50`). Defaults to `''`.
23+
* `cifmw_shiftstack_qa_repo`: (*string*) The repository containing the Openshift on Openstack QA automation. Defaults to `https://github.com/shiftstack/shiftstack-qa`.
2424
* `cifmw_shiftstack_run_playbook`: (*string*) The playbook to be run from the `cifmw_shiftstack_qa_repo` repository. Defaults to `ocp_testing.yaml`.
2525
* `cifmw_shiftstack_sc`: (*string*) The storage class to be used for PVC for the shiftstackclient pod. Defaults to `local-storage`.
2626
* `cifmw_shiftstack_shiftstackclient_artifacts_dir`: (*string*) The artifacts directory path for the shiftstackclient pod. Defaults to `/home/cloud-admin/artifacts`.
@@ -40,7 +40,7 @@ cifmw_run_test_role: shiftstack
4040
cifmw_run_test_shiftstack_testconfig:
4141
- 4.17_ovnkubernetes_ipi.yaml
4242
- 4.17_ovnkubernetes_upi.yaml
43-
cifmw_shiftstack_qa_gerrithub_change: refs/changes/29/1188429/50 #optional
43+
cifmw_shiftstack_qa_change_ref: refs/pull/5/head #optional
4444
45-
$ ansible-playbook deploy-edpm.yml --extra-vars "cifmw_run_tests=true cifmw_run_test_role=shiftstack cifmw_test_operator_stages=[] cifmw_openshift_kubeconfig={{ ansible_user_dir }}/.kube/config cifmw_run_test_shiftstack_testconfig=4.15_ovnkubernetes_ipi_va1.yaml cifmw_shiftstack_qa_gerrithub_change=refs/changes/29/1188429/50"
45+
$ ansible-playbook deploy-edpm.yml --extra-vars "cifmw_run_tests=true cifmw_run_test_role=shiftstack cifmw_test_operator_stages=[] cifmw_openshift_kubeconfig={{ ansible_user_dir }}/.kube/config cifmw_run_test_shiftstack_testconfig=4.15_ovnkubernetes_ipi_va1.yaml cifmw_shiftstack_qa_change_ref=refs/pull/5/head"
4646
```

roles/shiftstack/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ cifmw_shiftstack_hypervisor: "{{ hostvars[hostvars['controller-0']['cifmw_hyperv
3333
cifmw_shiftstack_installation_dir: "{{ cifmw_shiftstack_basedir }}/installation"
3434
cifmw_shiftstack_manifests_dir: "{{ cifmw_shiftstack_basedir }}/manifests"
3535
cifmw_shiftstack_project_name: "shiftstack"
36-
cifmw_shiftstack_qa_gerrithub_change: ""
37-
cifmw_shiftstack_qa_repo: "https://review.gerrithub.io/shiftstack/shiftstack-qa"
36+
cifmw_shiftstack_qa_change_ref: ""
37+
cifmw_shiftstack_qa_repo: "https://github.com/shiftstack/shiftstack-qa"
3838
cifmw_shiftstack_run_playbook: "ocp_testing.yaml"
3939
cifmw_shiftstack_sc: "local-storage"
4040
cifmw_shiftstack_shiftstackclient_artifacts_dir: "/home/cloud-admin/artifacts"

roles/shiftstack/tasks/exec_command_in_pod.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,58 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17+
- name: Clear previous exit code marker
18+
environment:
19+
PATH: "{{ cifmw_path }}"
20+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
21+
ansible.builtin.command:
22+
cmd: >-
23+
oc exec -n {{ namespace }} {{ pod_name }} --
24+
bash -c 'rm -f /tmp/cifmw_cmd_rc'
25+
changed_when: false
26+
failed_when: false
27+
1728
- name: Command execution block
1829
block:
1930
- name: Execute in the pod the command '{{ command }}'
2031
environment:
2132
PATH: "{{ cifmw_path }}"
2233
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
2334
ansible.builtin.command:
24-
cmd: "oc rsh -n {{ namespace }} {{ pod_name }} bash -c '{{ command }}'"
35+
cmd: >-
36+
oc exec -n {{ namespace }} {{ pod_name }} --
37+
bash -c '{{ command }}; echo $? > /tmp/cifmw_cmd_rc'
2538
register: pod_command_result
2639

40+
- name: Verify the command exit code from the pod
41+
environment:
42+
PATH: "{{ cifmw_path }}"
43+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
44+
ansible.builtin.command:
45+
cmd: >-
46+
oc exec -n {{ namespace }} {{ pod_name }} --
47+
bash -c 'cat /tmp/cifmw_cmd_rc'
48+
register: pod_exit_code
49+
changed_when: false
50+
until: pod_exit_code.rc == 0
51+
retries: 720
52+
delay: 10
53+
54+
- name: Fail if the command failed inside the pod
55+
ansible.builtin.fail:
56+
msg: >-
57+
"{{ command }}" reported success but the pod recorded
58+
exit code {{ pod_exit_code.stdout | trim }}.
59+
when: (pod_exit_code.stdout | trim) != '0'
60+
2761
rescue:
2862
- name: Fail when the command module fails
2963
ansible.builtin.fail:
30-
msg: '"{{ command }}" command execution failed with exit code "{{ pod_command_result.rc }}" and error: "{{ pod_command_result.stderr }}".'
64+
msg: >-
65+
"{{ command }}" failed.
66+
oc exit code: {{ pod_command_result.rc | default('N/A') }},
67+
pod exit code: {{ pod_exit_code.stdout | default('N/A') | trim }},
68+
stderr: {{ pod_command_result.stderr | default('') }}.
3169
3270
always:
3371
- name: Command execution log saving block
@@ -45,6 +83,7 @@
4583
pod_name: "{{ pod_name }}"
4684
command: "{{ command }}"
4785
pod_command_result: "{{ pod_command_result }}"
86+
pod_exit_code: "{{ pod_exit_code | default('N/A') }}"
4887
ansible.builtin.copy:
4988
content: "{{ command_info | to_nice_yaml }}"
5089
dest: "{{ cifmw_shiftstack_ansible_command_logs_dir }}/{{ current_date.stdout }}.{{ log_file_name }}"

roles/shiftstack/tasks/test_shiftstack.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
log_file_name: "clone_shiftstack_qa_repo.log"
2424
ansible.builtin.include_tasks: exec_command_in_pod.yml
2525

26-
- name: Fetch the gerrithub change '{{ cifmw_shiftstack_qa_gerrithub_change }}'
26+
- name: Fetch the change ref '{{ cifmw_shiftstack_qa_change_ref }}'
2727
vars:
2828
namespace: "{{ cifmw_shiftstack_client_pod_namespace }}"
2929
pod_name: "{{ cifmw_shiftstack_client_pod_name }}"
3030
command: >-
3131
cd shiftstack-qa &&
32-
git fetch {{ cifmw_shiftstack_qa_repo }} {{ cifmw_shiftstack_qa_gerrithub_change }} &&
32+
git fetch {{ cifmw_shiftstack_qa_repo }} {{ cifmw_shiftstack_qa_change_ref }} &&
3333
git checkout FETCH_HEAD
34-
log_file_name: "fetch_shiftstack_qa_gerrithub_change.log"
34+
log_file_name: "fetch_shiftstack_qa_change_ref.log"
3535
when:
36-
- cifmw_shiftstack_qa_gerrithub_change is defined
37-
- cifmw_shiftstack_qa_gerrithub_change != ''
36+
- cifmw_shiftstack_qa_change_ref is defined
37+
- cifmw_shiftstack_qa_change_ref != ''
3838
ansible.builtin.include_tasks: exec_command_in_pod.yml
3939

4040
- name: Install the ansible collections

0 commit comments

Comments
 (0)