From c974c62e11be91fc4fde5238b5f939152b9c6a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Tue, 18 Mar 2025 16:06:17 +0100 Subject: [PATCH 01/10] Switch context instead of temp kubeconfig --- .ibm/pipelines/utils.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 9c22db69ce..5158888bf2 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -37,20 +37,21 @@ save_all_pod_logs(){ droute_send() { if [[ "${OPENSHIFT_CI}" != "true" ]]; then return 0; fi - temp_kubeconfig=$(mktemp) # Create temporary KUBECONFIG to open second `oc` session - ( # Open subshell + local original_context=$(oc config current-context) # Save original context if [ -n "${PULL_NUMBER:-}" ]; then set +e fi - export KUBECONFIG="$temp_kubeconfig" local droute_version="1.2.2" local release_name=$1 local project=$2 local droute_project="droute" local metadata_output="data_router_metadata_output.json" - oc login --token="${RHDH_PR_OS_CLUSTER_TOKEN}" --server="${RHDH_PR_OS_CLUSTER_URL}" + oc config set-credentials temp-user --token="${RHDH_PR_OS_CLUSTER_TOKEN}" + oc config set-cluster temp-cluster --server="${RHDH_PR_OS_CLUSTER_URL}" + oc config set-context temp-context --user=temp-user --cluster=temp-cluster oc whoami --show-server + local droute_pod_name=$(oc get pods -n droute --no-headers -o custom-columns=":metadata.name" | grep ubi9-cert-rsync) local temp_droute=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c "mktemp -d") @@ -179,8 +180,7 @@ droute_send() { if [ -n "${PULL_NUMBER:-}" ]; then set -e fi - ) # Close subshell - rm -f "$temp_kubeconfig" # Destroy temporary KUBECONFIG + oc config use-context "$original_context" # Restore original context oc whoami --show-server } From 45459b8df28b21c5ea8c5364a7ba1b5652e4bf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Tue, 18 Mar 2025 16:06:37 +0100 Subject: [PATCH 02/10] Better waiting for droute retries --- .ibm/pipelines/utils.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 5158888bf2..410f93261f 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -98,12 +98,14 @@ droute_send() { # Send test by rsync to bastion pod. local max_attempts=5 - local wait_seconds=4 + local wait_seconds_step=0.5 for ((i = 1; i <= max_attempts; i++)); do echo "Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod." if output=$(oc rsync --progress=true --include="${metadata_output}" --include="${JUNIT_RESULTS}" --exclude="*" -n "${droute_project}" "${ARTIFACT_DIR}/${project}/" "${droute_project}/${droute_pod_name}:${temp_droute}/" 2>&1); then echo "$output" break + else + sleep $((wait_seconds_step * i)) fi if ((i == max_attempts)); then echo "Failed to rsync test results after ${max_attempts} attempts." @@ -121,8 +123,8 @@ droute_send() { && ${temp_droute}/droute-linux-amd64 version" # Send test results through DataRouter and save the request ID. - local max_attempts=5 - local wait_seconds=1 + local max_attempts=10 + local wait_seconds_step=0.5 for ((i = 1; i <= max_attempts; i++)); do echo "Attempt ${i} of ${max_attempts} to send test results through Data Router." if output=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c " @@ -137,6 +139,8 @@ droute_send() { echo "Test results successfully sent through Data Router." echo "Request ID: $DATA_ROUTER_REQUEST_ID" break + else + sleep $((wait_seconds_step * i)) fi fi From 18aa8cec6dda870bf58413ecf6ba23ab73ffd7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 09:16:46 +0100 Subject: [PATCH 03/10] Step 1 --- .ibm/pipelines/utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 410f93261f..42f2ea4fb0 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -98,7 +98,7 @@ droute_send() { # Send test by rsync to bastion pod. local max_attempts=5 - local wait_seconds_step=0.5 + local wait_seconds_step=1 for ((i = 1; i <= max_attempts; i++)); do echo "Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod." if output=$(oc rsync --progress=true --include="${metadata_output}" --include="${JUNIT_RESULTS}" --exclude="*" -n "${droute_project}" "${ARTIFACT_DIR}/${project}/" "${droute_project}/${droute_pod_name}:${temp_droute}/" 2>&1); then @@ -124,7 +124,7 @@ droute_send() { # Send test results through DataRouter and save the request ID. local max_attempts=10 - local wait_seconds_step=0.5 + local wait_seconds_step=1 for ((i = 1; i <= max_attempts; i++)); do echo "Attempt ${i} of ${max_attempts} to send test results through Data Router." if output=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c " From b56a0a1210b9d466c7facd58b88c36ff85726b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 10:32:23 +0100 Subject: [PATCH 04/10] Trap return --- .ibm/pipelines/utils.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 42f2ea4fb0..4899a59978 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -51,6 +51,7 @@ droute_send() { oc config set-cluster temp-cluster --server="${RHDH_PR_OS_CLUSTER_URL}" oc config set-context temp-context --user=temp-user --cluster=temp-cluster oc whoami --show-server + trap 'oc config use-context "$original_context" 2>/dev/null && oc whoami --show-server || true' RETURN local droute_pod_name=$(oc get pods -n droute --no-headers -o custom-columns=":metadata.name" | grep ubi9-cert-rsync) local temp_droute=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c "mktemp -d") @@ -184,6 +185,7 @@ droute_send() { if [ -n "${PULL_NUMBER:-}" ]; then set -e fi + oc config use-context "$original_context" # Restore original context oc whoami --show-server } From 55b076fdc123448b0f2f230dbb3a672a72595c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 11:48:47 +0100 Subject: [PATCH 05/10] Use context --- .ibm/pipelines/utils.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 4899a59978..9e6271cff9 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -50,8 +50,9 @@ droute_send() { oc config set-credentials temp-user --token="${RHDH_PR_OS_CLUSTER_TOKEN}" oc config set-cluster temp-cluster --server="${RHDH_PR_OS_CLUSTER_URL}" oc config set-context temp-context --user=temp-user --cluster=temp-cluster + oc config use-context temp-context oc whoami --show-server - trap 'oc config use-context "$original_context" 2>/dev/null && oc whoami --show-server || true' RETURN + trap 'oc config use-context "$original_context" 2>/dev/null && oc whoami --show-server || true' RETURN EXIT local droute_pod_name=$(oc get pods -n droute --no-headers -o custom-columns=":metadata.name" | grep ubi9-cert-rsync) local temp_droute=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c "mktemp -d") From d4a1a99e3ae7b9baa7948bd40a13003993f9ed71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 11:50:04 +0100 Subject: [PATCH 06/10] return --- .ibm/pipelines/utils.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 9e6271cff9..66c262a3c4 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -52,7 +52,7 @@ droute_send() { oc config set-context temp-context --user=temp-user --cluster=temp-cluster oc config use-context temp-context oc whoami --show-server - trap 'oc config use-context "$original_context" 2>/dev/null && oc whoami --show-server || true' RETURN EXIT + trap 'oc config use-context "$original_context" 2>/dev/null && oc whoami --show-server || true' RETURN local droute_pod_name=$(oc get pods -n droute --no-headers -o custom-columns=":metadata.name" | grep ubi9-cert-rsync) local temp_droute=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c "mktemp -d") @@ -105,7 +105,7 @@ droute_send() { echo "Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod." if output=$(oc rsync --progress=true --include="${metadata_output}" --include="${JUNIT_RESULTS}" --exclude="*" -n "${droute_project}" "${ARTIFACT_DIR}/${project}/" "${droute_project}/${droute_pod_name}:${temp_droute}/" 2>&1); then echo "$output" - break + return else sleep $((wait_seconds_step * i)) fi @@ -140,7 +140,7 @@ droute_send() { [ -n "$DATA_ROUTER_REQUEST_ID" ]; then echo "Test results successfully sent through Data Router." echo "Request ID: $DATA_ROUTER_REQUEST_ID" - break + return else sleep $((wait_seconds_step * i)) fi From d620504750700910191f8760810dd49ea02c1fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 12:42:22 +0100 Subject: [PATCH 07/10] Update utils.sh --- .ibm/pipelines/utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 66c262a3c4..339f6084e6 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -105,7 +105,6 @@ droute_send() { echo "Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod." if output=$(oc rsync --progress=true --include="${metadata_output}" --include="${JUNIT_RESULTS}" --exclude="*" -n "${droute_project}" "${ARTIFACT_DIR}/${project}/" "${droute_project}/${droute_pod_name}:${temp_droute}/" 2>&1); then echo "$output" - return else sleep $((wait_seconds_step * i)) fi @@ -115,6 +114,7 @@ droute_send() { echo "${output}" echo "Troubleshooting steps:" echo "1. Restart $droute_pod_name in $droute_project project/namespace" + return 1 fi done @@ -140,7 +140,6 @@ droute_send() { [ -n "$DATA_ROUTER_REQUEST_ID" ]; then echo "Test results successfully sent through Data Router." echo "Request ID: $DATA_ROUTER_REQUEST_ID" - return else sleep $((wait_seconds_step * i)) fi @@ -154,6 +153,7 @@ droute_send() { echo "1. Restart $droute_pod_name in $droute_project project/namespace" echo "2. Check the Data Router documentation: https://spaces.redhat.com/pages/viewpage.action?pageId=115488042" echo "3. Ask for help at Slack: #forum-dno-datarouter" + return 1 fi done From 47917da14cf55c5f7a453c2c62808ecc5c525bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 13:39:09 +0100 Subject: [PATCH 08/10] Update utils.sh --- .ibm/pipelines/utils.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 339f6084e6..014ddc79a4 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -37,7 +37,8 @@ save_all_pod_logs(){ droute_send() { if [[ "${OPENSHIFT_CI}" != "true" ]]; then return 0; fi - local original_context=$(oc config current-context) # Save original context + local original_context + original_context=$(oc config current-context) # Save original context if [ -n "${PULL_NUMBER:-}" ]; then set +e fi @@ -52,7 +53,7 @@ droute_send() { oc config set-context temp-context --user=temp-user --cluster=temp-cluster oc config use-context temp-context oc whoami --show-server - trap 'oc config use-context "$original_context" 2>/dev/null && oc whoami --show-server || true' RETURN + trap 'oc config use-context "$original_context"' RETURN local droute_pod_name=$(oc get pods -n droute --no-headers -o custom-columns=":metadata.name" | grep ubi9-cert-rsync) local temp_droute=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c "mktemp -d") From 2c07f1e558edc6630ba49685d2805b2060b87f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 15:12:18 +0100 Subject: [PATCH 09/10] Test for errors in kubernetes action --- .../plugins/kubernetes-actions/kubernetes-actions.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e-tests/playwright/e2e/plugins/kubernetes-actions/kubernetes-actions.spec.ts b/e2e-tests/playwright/e2e/plugins/kubernetes-actions/kubernetes-actions.spec.ts index 5c21f32633..a08335ab6b 100644 --- a/e2e-tests/playwright/e2e/plugins/kubernetes-actions/kubernetes-actions.spec.ts +++ b/e2e-tests/playwright/e2e/plugins/kubernetes-actions/kubernetes-actions.spec.ts @@ -1,4 +1,4 @@ -import { Page, test } from "@playwright/test"; +import { expect, Page, test } from "@playwright/test"; import { Common, setupBrowser } from "../../../utils/common"; import { UIhelper } from "../../../utils/ui-helper"; import { KubeClient } from "../../../utils/kube-client"; @@ -36,6 +36,9 @@ test.describe("Test Kubernetes Actions plugin", () => { await page.waitForSelector( `${UI_HELPER_ELEMENTS.MuiTypography}:has-text("second")`, ); + await expect( + page.locator(`${UI_HELPER_ELEMENTS.MuiTypography}:has-text("Error")`), + ).not.toBeVisible(); await kubeClient.getNamespaceByName(namespace); }); From f8c35f20b26b6044ea1b25e57b46a07f54228384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbyn=C4=9Bk=20Dr=C3=A1pela?= Date: Wed, 19 Mar 2025 15:12:23 +0100 Subject: [PATCH 10/10] Fixes Update utils.sh Update utils.sh Update utils.sh --- .ibm/pipelines/utils.sh | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.ibm/pipelines/utils.sh b/.ibm/pipelines/utils.sh index 014ddc79a4..c0f24ade9b 100755 --- a/.ibm/pipelines/utils.sh +++ b/.ibm/pipelines/utils.sh @@ -37,8 +37,9 @@ save_all_pod_logs(){ droute_send() { if [[ "${OPENSHIFT_CI}" != "true" ]]; then return 0; fi - local original_context - original_context=$(oc config current-context) # Save original context + local original_context + original_context=$(oc config current-context) # Save original context + ( # Open subshell if [ -n "${PULL_NUMBER:-}" ]; then set +e fi @@ -106,16 +107,16 @@ droute_send() { echo "Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod." if output=$(oc rsync --progress=true --include="${metadata_output}" --include="${JUNIT_RESULTS}" --exclude="*" -n "${droute_project}" "${ARTIFACT_DIR}/${project}/" "${droute_project}/${droute_pod_name}:${temp_droute}/" 2>&1); then echo "$output" - else - sleep $((wait_seconds_step * i)) - fi - if ((i == max_attempts)); then + break + elif ((i == max_attempts)); then echo "Failed to rsync test results after ${max_attempts} attempts." echo "Last rsync error details:" echo "${output}" echo "Troubleshooting steps:" echo "1. Restart $droute_pod_name in $droute_project project/namespace" return 1 + else + sleep $((wait_seconds_step * i)) fi done @@ -130,23 +131,19 @@ droute_send() { local wait_seconds_step=1 for ((i = 1; i <= max_attempts; i++)); do echo "Attempt ${i} of ${max_attempts} to send test results through Data Router." - if output=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c " + output=$(oc exec -n "${droute_project}" "${droute_pod_name}" -- /bin/bash -c " ${temp_droute}/droute-linux-amd64 send --metadata ${temp_droute}/${metadata_output} \ --url '${DATA_ROUTER_URL}' \ --username '${DATA_ROUTER_USERNAME}' \ --password '${DATA_ROUTER_PASSWORD}' \ --results '${temp_droute}/${JUNIT_RESULTS}' \ - --verbose" 2>&1); then - if DATA_ROUTER_REQUEST_ID=$(echo "$output" | grep "request:" | awk '{print $2}') && - [ -n "$DATA_ROUTER_REQUEST_ID" ]; then - echo "Test results successfully sent through Data Router." - echo "Request ID: $DATA_ROUTER_REQUEST_ID" - else - sleep $((wait_seconds_step * i)) - fi - fi - - if ((i == max_attempts)); then + --verbose" 2>&1) + if DATA_ROUTER_REQUEST_ID=$(echo "$output" | grep "request:" | awk '{print $2}') && + [ -n "$DATA_ROUTER_REQUEST_ID" ]; then + echo "Test results successfully sent through Data Router." + echo "Request ID: $DATA_ROUTER_REQUEST_ID" + break + elif ((i == max_attempts)); then echo "Failed to send test results after ${max_attempts} attempts." echo "Last Data Router error details:" echo "${output}" @@ -155,6 +152,8 @@ droute_send() { echo "2. Check the Data Router documentation: https://spaces.redhat.com/pages/viewpage.action?pageId=115488042" echo "3. Ask for help at Slack: #forum-dno-datarouter" return 1 + else + sleep $((wait_seconds_step * i)) fi done @@ -187,7 +186,7 @@ droute_send() { if [ -n "${PULL_NUMBER:-}" ]; then set -e fi - + ) # Close subshell oc config use-context "$original_context" # Restore original context oc whoami --show-server }