Skip to content

Commit 4dd8af5

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 4dd8af5

4 files changed

Lines changed: 49 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: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,56 @@
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+
failed_when: false
26+
1727
- name: Command execution block
1828
block:
1929
- name: Execute in the pod the command '{{ command }}'
2030
environment:
2131
PATH: "{{ cifmw_path }}"
2232
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
2333
ansible.builtin.command:
24-
cmd: "oc rsh -n {{ namespace }} {{ pod_name }} bash -c '{{ command }}'"
34+
cmd: >-
35+
oc exec -n {{ namespace }} {{ pod_name }} --
36+
bash -c '{{ command }}; echo $? > /tmp/cifmw_cmd_rc'
2537
register: pod_command_result
2638

39+
- name: Verify the command exit code from the pod
40+
environment:
41+
PATH: "{{ cifmw_path }}"
42+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
43+
ansible.builtin.command:
44+
cmd: >-
45+
oc exec -n {{ namespace }} {{ pod_name }} --
46+
bash -c 'cat /tmp/cifmw_cmd_rc'
47+
register: pod_exit_code
48+
until: pod_exit_code.rc == 0
49+
retries: 720
50+
delay: 10
51+
52+
- name: Fail if the command failed inside the pod
53+
ansible.builtin.fail:
54+
msg: >-
55+
"{{ command }}" reported success but the pod recorded
56+
exit code {{ pod_exit_code.stdout | trim }}.
57+
when: (pod_exit_code.stdout | trim) != '0'
58+
2759
rescue:
2860
- name: Fail when the command module fails
2961
ansible.builtin.fail:
30-
msg: '"{{ command }}" command execution failed with exit code "{{ pod_command_result.rc }}" and error: "{{ pod_command_result.stderr }}".'
62+
msg: >-
63+
"{{ command }}" failed.
64+
oc exit code: {{ pod_command_result.rc | default('N/A') }},
65+
pod exit code: {{ pod_exit_code.stdout | default('N/A') | trim }},
66+
stderr: {{ pod_command_result.stderr | default('') }}.
3167
3268
always:
3369
- name: Command execution log saving block

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)