Skip to content

Commit 39e45d4

Browse files
zdrapelakrisnababu
authored andcommitted
rhdh: gzip junit results in SHARED_DIR and align overlays resource limits (openshift#81313)
* rhdh: gzip junit results in SHARED_DIR to avoid Secret size limit The junit-results.xml on the overlays main branch exceeds the Kubernetes Secret 1 MiB size limit, causing the SHARED_DIR Secret update to fail and leaving the send-data-router step with no junit file to report. Fix by gzipping junit XML before writing to SHARED_DIR (XML compresses ~10-15x) and decompressing in the data-router steps to ARTIFACT_DIR before processing and sending to Data Router. Changes: - overlays ocp-helm: gzip junit + 800 KB size check before SHARED_DIR - overlays send-data-router: decompress .gz to ARTIFACT_DIR, fall back to plain XML for backward compat - rhdh send-data-router: same decompression + fallback (preventive, activated by a follow-up PR in redhat-developer/rhdh) Assisted-by: OpenCode * rhdh overlays: align ocp-helm resource requests/limits with rhdh Match the RHDH ocp-helm step resource specs: - CPU: 1 request / 10 limit (was 2 / 4) - Memory: 1Gi request / 5Gi limit (was 6Gi / 8Gi) Assisted-by: OpenCode * rhdh: harden data-router scripts error handling - Remove set +o nounset (all env vars have defaults in ref YAML) - Add explicit exit 0 to guarantee the step never fails the CI job - Change ERROR to WARNING for missing junit (expected in overflow case) - Fix unbound GIT_PR_NUMBER and TAG_NAME references in rhdh data-router - Add comments explaining the set +o errexit contract Assisted-by: OpenCode
1 parent dc507e3 commit 39e45d4

4 files changed

Lines changed: 75 additions & 23 deletions

File tree

ci-operator/step-registry/redhat-developer/rhdh-plugin-export-overlays/ocp/helm/redhat-developer-rhdh-plugin-export-overlays-ocp-helm-commands.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,18 @@ collect_artifacts() {
206206
cp -a node_modules/.cache/e2e-test-results "${ARTIFACT_DIR}/" 2>&1 || echo "[WARNING] e2e-test-results not found"
207207
fi
208208
# Copy JUnit results to SHARED_DIR for data-router step
209+
# Gzip to stay under Kubernetes Secret 1 MiB limit (raw XML can exceed it)
209210
if [[ -f "playwright-report/junit-results.xml" ]]; then
210-
cp "playwright-report/junit-results.xml" "${SHARED_DIR}/"
211-
echo "[INFO] Copied junit-results.xml to ${SHARED_DIR}/"
211+
gzip -c "playwright-report/junit-results.xml" > "${SHARED_DIR}/junit-results.xml.gz"
212+
local gz_size
213+
gz_size=$(stat -c%s "${SHARED_DIR}/junit-results.xml.gz" 2>/dev/null || stat -f%z "${SHARED_DIR}/junit-results.xml.gz")
214+
local max_size=$((800 * 1024))
215+
if (( gz_size > max_size )); then
216+
echo "[WARNING] junit-results.xml.gz is $(( gz_size / 1024 )) KB, exceeds $(( max_size / 1024 )) KB limit. Removing from SHARED_DIR to prevent Secret update failure."
217+
rm -f "${SHARED_DIR}/junit-results.xml.gz"
218+
else
219+
echo "[INFO] Copied junit-results.xml.gz to ${SHARED_DIR}/ ($(( gz_size / 1024 )) KB)"
220+
fi
212221
fi
213222
}
214223

ci-operator/step-registry/redhat-developer/rhdh-plugin-export-overlays/ocp/helm/redhat-developer-rhdh-plugin-export-overlays-ocp-helm-ref.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ ref:
3333
timeout: 3h30m0s
3434
resources:
3535
limits:
36-
memory: 8Gi
37-
cpu: "4"
36+
cpu: "10"
37+
memory: 5Gi
3838
requests:
39-
cpu: "2"
40-
memory: 6Gi
39+
cpu: "1"
40+
memory: 1Gi

ci-operator/step-registry/redhat-developer/rhdh-plugin-export-overlays/send/data-router/redhat-developer-rhdh-plugin-export-overlays-send-data-router-commands.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22

3+
# This post step must never fail the overall CI job — it is a reporting step.
4+
# errexit is disabled so errors are handled internally (retries, warnings, graceful skips).
35
set +o errexit
4-
set +o nounset
56

67
# Skip data router reporting when job was triggered via Gangway API with overrides
78
OVERRIDE_VARS=(
@@ -87,16 +88,27 @@ get_artifacts_url() {
8788
process_junit_file() {
8889
echo "Processing JUnit file for Data Router compatibility..."
8990

90-
local junit_file="${SHARED_DIR}/junit-results.xml"
91-
if [[ ! -f "$junit_file" ]]; then
91+
mkdir -p "${ARTIFACT_DIR}/data-router"
92+
93+
local junit_gz="${SHARED_DIR}/junit-results.xml.gz"
94+
local junit_shared="${SHARED_DIR}/junit-results.xml"
95+
local junit_file="${ARTIFACT_DIR}/data-router/junit-results.xml"
96+
97+
# Decompress gzipped junit to ARTIFACT_DIR (new format); fall back to plain XML (backward compat)
98+
if [[ -f "$junit_gz" ]]; then
99+
gunzip -c "$junit_gz" > "$junit_file"
100+
echo "Decompressed junit-results.xml.gz -> ${junit_file}"
101+
elif [[ -f "$junit_shared" ]]; then
102+
cp "$junit_shared" "$junit_file"
103+
echo "Copied junit-results.xml from SHARED_DIR to ARTIFACT_DIR"
104+
else
92105
echo "WARNING: junit-results.xml not found in ${SHARED_DIR}, skipping processing"
93106
return
94107
fi
95108

96109
echo "Processing: junit-results.xml"
97110

98111
# Create backup in ARTIFACT_DIR
99-
mkdir -p "${ARTIFACT_DIR}/data-router"
100112
cp "$junit_file" "${ARTIFACT_DIR}/data-router/junit-results.xml.original.xml"
101113

102114
# Construct artifacts URL for attachment placeholder replacement
@@ -253,9 +265,10 @@ main() {
253265
local output=""
254266
local DATA_ROUTER_REQUEST_ID=""
255267

256-
if [[ ! -f "${SHARED_DIR}/junit-results.xml" ]]; then
257-
echo "ERROR: No JUnit results file (junit-results.xml) found in ${SHARED_DIR}"
258-
return
268+
local junit_for_send="${ARTIFACT_DIR}/data-router/junit-results.xml"
269+
if [[ ! -f "$junit_for_send" ]]; then
270+
echo "WARNING: No JUnit results file found (processed by process_junit_file), skipping Data Router upload"
271+
return 0
259272
fi
260273

261274
for ((i = 1; i <= max_attempts; i++)); do
@@ -265,7 +278,7 @@ main() {
265278
--url "${DATA_ROUTER_URL}" \
266279
--username "${DATA_ROUTER_USERNAME}" \
267280
--password "${DATA_ROUTER_PASSWORD}" \
268-
--results "${SHARED_DIR}/junit-results.xml" \
281+
--results "$junit_for_send" \
269282
--verbose --wirelog 2>&1) && \
270283
DATA_ROUTER_REQUEST_ID=$(echo "$output" | grep "request:" | awk '{print $2}') &&
271284
[ -n "$DATA_ROUTER_REQUEST_ID" ]; then
@@ -320,3 +333,6 @@ main() {
320333
}
321334

322335
main
336+
337+
# Ensure this reporting step never fails the CI job regardless of what main() returned
338+
exit 0

ci-operator/step-registry/redhat-developer/rhdh/send/data-router/redhat-developer-rhdh-send-data-router-commands.sh

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22

3+
# This post step must never fail the overall CI job — it is a reporting step.
4+
# errexit is disabled so errors are handled internally (retries, warnings, graceful skips).
35
set +o errexit
4-
set +o nounset
56

67
# Skip data router reporting when job was triggered via Gangway API with overrides
78
OVERRIDE_VARS=(
@@ -96,7 +97,30 @@ get_artifacts_url() {
9697
process_junit_files() {
9798
echo "📝 Processing JUnit files for Data Router compatibility..."
9899

99-
for junit_file in "${SHARED_DIR}"/junit-results-*.xml; do
100+
mkdir -p "${ARTIFACT_DIR}/data-router"
101+
102+
# Decompress gzipped junit files to ARTIFACT_DIR (new format); copy plain XML as fallback (backward compat)
103+
for junit_gz in "${SHARED_DIR}"/junit-results-*.xml.gz; do
104+
if [[ -f "$junit_gz" ]]; then
105+
local filename
106+
filename=$(basename "${junit_gz%.gz}")
107+
gunzip -c "$junit_gz" > "${ARTIFACT_DIR}/data-router/${filename}"
108+
echo "Decompressed $(basename "$junit_gz") -> ${ARTIFACT_DIR}/data-router/${filename}"
109+
fi
110+
done
111+
for junit_shared in "${SHARED_DIR}"/junit-results-*.xml; do
112+
if [[ -f "$junit_shared" ]]; then
113+
local filename
114+
filename=$(basename "$junit_shared")
115+
# Only copy if not already decompressed from .gz
116+
if [[ ! -f "${ARTIFACT_DIR}/data-router/${filename}" ]]; then
117+
cp "$junit_shared" "${ARTIFACT_DIR}/data-router/${filename}"
118+
echo "Copied ${filename} from SHARED_DIR to ARTIFACT_DIR"
119+
fi
120+
fi
121+
done
122+
123+
for junit_file in "${ARTIFACT_DIR}"/data-router/junit-results-*.xml; do
100124
if [[ ! -f "$junit_file" ]]; then
101125
continue
102126
fi
@@ -204,9 +228,9 @@ save_data_router_metadata() {
204228
--arg name "$JOB_NAME" \
205229
--arg description "[View job run details](${JOB_URL})" \
206230
--arg job_type "$JOB_TYPE" \
207-
--arg pr "$GIT_PR_NUMBER" \
231+
--arg pr "${GIT_PR_NUMBER:-}" \
208232
--arg job_name "$JOB_NAME" \
209-
--arg tag_name "$TAG_NAME" \
233+
--arg tag_name "${TAG_NAME:-}" \
210234
--arg install_method "$install_method" \
211235
--arg cluster_type "$cluster_type" \
212236
--arg container_platform "$CONTAINER_PLATFORM" \
@@ -270,25 +294,25 @@ main() {
270294
for ((i = 1; i <= max_attempts; i++)); do
271295
echo "Attempt ${i} of ${max_attempts} to send test results through Data Router."
272296

273-
# Check if JUnit results files exist in SHARED_DIR
297+
# Check if JUnit results files exist in ARTIFACT_DIR (decompressed by process_junit_files)
274298
local junit_files_found=false
275-
for file in "${SHARED_DIR}"/junit-*.xml; do
299+
for file in "${ARTIFACT_DIR}"/data-router/junit-*.xml; do
276300
if [[ -f "$file" ]]; then
277301
junit_files_found=true
278302
break
279303
fi
280304
done
281305

282306
if [[ "$junit_files_found" == false ]]; then
283-
echo "ERROR: No JUnit results files (junit-*.xml) found in ${SHARED_DIR}"
284-
return
307+
echo "WARNING: No JUnit results files (junit-*.xml) found in ${ARTIFACT_DIR}/data-router, skipping Data Router upload"
308+
return 0
285309
fi
286310

287311
if output=$(droute send --metadata "$(get_metadata_output_path)" \
288312
--url "${DATA_ROUTER_URL}" \
289313
--username "${DATA_ROUTER_USERNAME}" \
290314
--password "${DATA_ROUTER_PASSWORD}" \
291-
--results "${SHARED_DIR}/junit-*.xml" \
315+
--results "${ARTIFACT_DIR}/data-router/junit-*.xml" \
292316
--verbose --wirelog 2>&1) && \
293317
DATA_ROUTER_REQUEST_ID=$(echo "$output" | grep "request:" | awk '{print $2}') &&
294318
[ -n "$DATA_ROUTER_REQUEST_ID" ]; then
@@ -349,3 +373,6 @@ main() {
349373
}
350374

351375
main
376+
377+
# Ensure this reporting step never fails the CI job regardless of what main() returned
378+
exit 0

0 commit comments

Comments
 (0)