From e3072fd5587b4ed92761ec9904cd62d5f316b569 Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Wed, 18 Feb 2026 16:29:33 -0300 Subject: [PATCH 1/3] feat(ci): skip pod log collection and write TESTS_PASSED marker on success On successful PR runs, save_all_pod_logs in testing::check_and_test was collecting logs from every pod in the namespace unconditionally. This adds a condition to skip collection when tests pass, and writes a TESTS_PASSED marker file to $SHARED_DIR on clean exit so that the openshift/release post-phase (gather-extra, must-gather) can skip heavy artifact collection. Ref: RHIDP-12291 Co-Authored-By: Claude Opus 4.6 --- .ibm/pipelines/cleanup.sh | 7 +++++++ .ibm/pipelines/lib/testing.sh | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.ibm/pipelines/cleanup.sh b/.ibm/pipelines/cleanup.sh index f69c570902..716ccb8dd7 100755 --- a/.ibm/pipelines/cleanup.sh +++ b/.ibm/pipelines/cleanup.sh @@ -13,6 +13,13 @@ cleanup() { log::error "Exited with an error, setting OVERALL_RESULT to 1" save_overall_result 1 fi + # Write TESTS_PASSED marker to SHARED_DIR for gather-extra/must-gather optimization. + # When present, the openshift/release post-phase steps can skip heavy artifact collection. + if [[ "${OVERALL_RESULT:-1}" == "0" && -n "${SHARED_DIR:-}" ]]; then + touch "${SHARED_DIR}/TESTS_PASSED" + log::info "TESTS_PASSED marker written to ${SHARED_DIR}" + fi + if [[ "${OPENSHIFT_CI}" == "true" ]]; then log::info "Cleaning up before exiting" case "$JOB_NAME" in diff --git a/.ibm/pipelines/lib/testing.sh b/.ibm/pipelines/lib/testing.sh index 4ba17a1942..264511a7a8 100644 --- a/.ibm/pipelines/lib/testing.sh +++ b/.ibm/pipelines/lib/testing.sh @@ -232,6 +232,8 @@ testing::check_and_test() { return 1 fi + local _deployment_failed=false + if testing::check_backstage_running "${release_name}" "${namespace}" "${url}" "${max_attempts}" "${wait_seconds}"; then echo "Display pods for verification..." oc get pods -n "${namespace}" @@ -241,6 +243,7 @@ testing::check_and_test() { testing::run_tests "${release_name}" "${namespace}" "${playwright_project}" "${url}" "${artifacts_subdir}" fi else + _deployment_failed=true echo "Backstage is not running. Marking deployment as failed and continuing..." CURRENT_DEPLOYMENT=$((CURRENT_DEPLOYMENT + 1)) save_status_deployment_namespace $CURRENT_DEPLOYMENT "$namespace" @@ -248,7 +251,14 @@ testing::check_and_test() { save_status_test_failed $CURRENT_DEPLOYMENT true save_overall_result 1 fi - save_all_pod_logs "$namespace" + + # Collect pod logs only on failure to speed up successful PR runs. + # On backstage failure, check_backstage_running already collects logs internally. + if [[ "$_deployment_failed" == "true" ]] || [[ "${STATUS_TEST_FAILED[$CURRENT_DEPLOYMENT]:-}" == "true" ]]; then + save_all_pod_logs "$namespace" + else + log::info "Tests passed — skipping pod log collection for namespace: ${namespace}" + fi return 0 } From 5ffc1b2d60737a81eb097e77f925e2e0a15c4413 Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Feb 2026 08:51:26 -0300 Subject: [PATCH 2/3] fix: avoid double pod log collection on deployment failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit check_backstage_running already calls save_all_pod_logs internally before returning false. Only call save_all_pod_logs when deployment succeeded but tests failed — skip both when deployment failed (already collected) and when tests passed (not needed). Co-Authored-By: Claude Opus 4.6 --- .ibm/pipelines/lib/testing.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.ibm/pipelines/lib/testing.sh b/.ibm/pipelines/lib/testing.sh index 264511a7a8..043d5e6f13 100644 --- a/.ibm/pipelines/lib/testing.sh +++ b/.ibm/pipelines/lib/testing.sh @@ -252,11 +252,12 @@ testing::check_and_test() { save_overall_result 1 fi - # Collect pod logs only on failure to speed up successful PR runs. - # On backstage failure, check_backstage_running already collects logs internally. - if [[ "$_deployment_failed" == "true" ]] || [[ "${STATUS_TEST_FAILED[$CURRENT_DEPLOYMENT]:-}" == "true" ]]; then + # Collect pod logs only on test failure to speed up successful PR runs. + # Skip when deployment failed — check_backstage_running already collects logs internally. + # Skip when tests passed — no debugging artifacts needed. + if [[ "$_deployment_failed" == "false" ]] && [[ "${STATUS_TEST_FAILED[$CURRENT_DEPLOYMENT]:-}" == "true" ]]; then save_all_pod_logs "$namespace" - else + elif [[ "$_deployment_failed" == "false" ]]; then log::info "Tests passed — skipping pod log collection for namespace: ${namespace}" fi return 0 From b60ea77f81463f1c2c8d52d86bf88c0caf9b40ad Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Feb 2026 10:27:11 -0300 Subject: [PATCH 3/3] refactor: move save_all_pod_logs out of check_backstage_running Per review feedback: check_backstage_running is only called from check_and_test, so pod log collection belongs in the caller. This removes the _deployment_failed flag and centralizes the decision in check_and_test using STATUS_TEST_FAILED/STATUS_FAILED_TO_DEPLOY. Co-Authored-By: Claude Opus 4.6 --- .ibm/pipelines/lib/testing.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.ibm/pipelines/lib/testing.sh b/.ibm/pipelines/lib/testing.sh index 043d5e6f13..aff7492ca1 100644 --- a/.ibm/pipelines/lib/testing.sh +++ b/.ibm/pipelines/lib/testing.sh @@ -187,7 +187,6 @@ testing::check_backstage_running() { oc get events -n "${namespace}" --sort-by='.lastTimestamp' | tail -20 mkdir -p "${ARTIFACT_DIR}/${namespace}" cp -a "/tmp/${LOGFILE}" "${ARTIFACT_DIR}/${namespace}/" || true - save_all_pod_logs "${namespace}" return 1 fi @@ -199,7 +198,6 @@ testing::check_backstage_running() { oc get events -n "${namespace}" --sort-by='.lastTimestamp' | tail -10 mkdir -p "${ARTIFACT_DIR}/${namespace}" cp -a "/tmp/${LOGFILE}" "${ARTIFACT_DIR}/${namespace}/" || true - save_all_pod_logs "${namespace}" return 1 } @@ -232,8 +230,6 @@ testing::check_and_test() { return 1 fi - local _deployment_failed=false - if testing::check_backstage_running "${release_name}" "${namespace}" "${url}" "${max_attempts}" "${wait_seconds}"; then echo "Display pods for verification..." oc get pods -n "${namespace}" @@ -243,7 +239,6 @@ testing::check_and_test() { testing::run_tests "${release_name}" "${namespace}" "${playwright_project}" "${url}" "${artifacts_subdir}" fi else - _deployment_failed=true echo "Backstage is not running. Marking deployment as failed and continuing..." CURRENT_DEPLOYMENT=$((CURRENT_DEPLOYMENT + 1)) save_status_deployment_namespace $CURRENT_DEPLOYMENT "$namespace" @@ -252,12 +247,10 @@ testing::check_and_test() { save_overall_result 1 fi - # Collect pod logs only on test failure to speed up successful PR runs. - # Skip when deployment failed — check_backstage_running already collects logs internally. - # Skip when tests passed — no debugging artifacts needed. - if [[ "$_deployment_failed" == "false" ]] && [[ "${STATUS_TEST_FAILED[$CURRENT_DEPLOYMENT]:-}" == "true" ]]; then + # Collect pod logs only on failure to speed up successful PR runs. + if [[ "${STATUS_TEST_FAILED[$CURRENT_DEPLOYMENT]:-}" == "true" || "${STATUS_FAILED_TO_DEPLOY[$CURRENT_DEPLOYMENT]:-}" == "true" ]]; then save_all_pod_logs "$namespace" - elif [[ "$_deployment_failed" == "false" ]]; then + else log::info "Tests passed — skipping pod log collection for namespace: ${namespace}" fi return 0