Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): droute with bastion pod - switch contexts and enhanced waiting in retries #2599

Merged
merged 10 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions .ibm/pipelines/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,25 @@ 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
local original_context
original_context=$(oc config current-context) # Save original context
( # Open subshell
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 config use-context temp-context
oc whoami --show-server
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")

Expand Down Expand Up @@ -97,19 +102,21 @@ droute_send() {

# Send test by rsync to bastion pod.
local max_attempts=5
local wait_seconds=4
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
echo "$output"
break
fi
if ((i == max_attempts)); then
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

Expand All @@ -120,33 +127,33 @@ 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=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"
break
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}"
echo "Troubleshooting steps:"
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
else
sleep $((wait_seconds_step * i))
fi
done

Expand Down Expand Up @@ -180,7 +187,7 @@ droute_send() {
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
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
});

Expand Down
Loading