Skip to content

Commit c6543a9

Browse files
committed
fix: reconfigure pac if github throws error
- re-annotate the component to let it retry onboarding Signed-off-by: Scott Hebert <[email protected]>
1 parent d4f8d46 commit c6543a9

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

integration-tests/lib/test-functions.sh

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,55 @@ create_kubernetes_resources() {
239239
# Modifies global variables: component_pr, pr_number
240240
# Relies on global variables: component_name, tenant_namespace
241241
wait_for_component_initialization() {
242-
echo -n "Waiting for component ${component_name} in namespace ${tenant_namespace} to be initialized: "
242+
echo "Waiting for component ${component_name} in namespace ${tenant_namespace} to be initialized..."
243+
244+
local max_attempts=60 # 10 minutes with 10-second intervals
245+
local attempt=1
243246
local component_annotations=""
244-
while [ -z "${component_annotations}" ]; do
245-
sleep 1
246-
echo -n "."
247+
local initialization_success=false
248+
249+
while [ $attempt -le $max_attempts ]; do
250+
echo "Initialization check attempt ${attempt}/${max_attempts}..."
251+
252+
# Try to get component annotations
247253
component_annotations=$(kubectl get component/"${component_name}" -n "${tenant_namespace}" -ojson 2>/dev/null | \
248254
jq -r --arg k "build.appstudio.openshift.io/status" '.metadata.annotations[$k] // ""')
255+
256+
if [ -n "${component_annotations}" ]; then
257+
echo "✅ Component initialized successfully"
258+
259+
# component_pr is made global by not declaring it local
260+
component_pr=$(jq -r '.pac."merge-url" // ""' <<< "${component_annotations}")
261+
if [ -n "${component_pr}" ]; then
262+
initialization_success=true
263+
break
264+
else
265+
log_warning "Could not get component PR from annotations: ${component_annotations}"
266+
echo "Waiting 10 seconds before retry..."
267+
sleep 10
268+
echo "Requesting a new configure-pac..."
269+
kubectl annotate components/${component_name} build.appstudio.openshift.io/request=configure-pac -n "${tenant_namespace}"
270+
fi
271+
272+
else
273+
echo "⚠️ Component not yet initialized (attempt ${attempt}/${max_attempts})"
274+
275+
# Wait before retrying (except on the last attempt)
276+
if [ $attempt -lt $max_attempts ]; then
277+
echo "Waiting 10 seconds before retry..."
278+
sleep 10
279+
fi
280+
fi
281+
282+
attempt=$((attempt + 1))
249283
done
250-
echo ""
251-
echo "️✅️ Initialized."
252284

253-
# component_pr is made global by not declaring it local
254-
component_pr=$(jq -r '.pac."merge-url" // ""' <<< "${component_annotations}")
255-
if [ -z "${component_pr}" ]; then
256-
log_error "Could not get component PR from annotations: ${component_annotations}"
285+
# Check if initialization ultimately succeeded
286+
if [ "$initialization_success" = false ]; then
287+
echo "🔴 error: component ${component_name} failed to initialize after ${max_attempts} attempts ($(($max_attempts * 10 / 60)) minutes)"
288+
echo " - Component may not exist in namespace ${tenant_namespace}"
289+
echo " - Component creation may have failed"
290+
exit 1
257291
fi
258292

259293
# pr_number is made global by not declaring it local
@@ -286,7 +320,7 @@ merge_github_pr() {
286320
# Retry loop for PR merge
287321
while [ $attempt -le $max_attempts ] && [ "$success" = false ]; do
288322
echo "Merge attempt ${attempt}/${max_attempts}..."
289-
323+
290324
set +e
291325
merge_result=$(curl -L \
292326
-X PUT \

tasks/managed/collect-data/collect-data.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
annotations:
77
tekton.dev/pipelines.minVersion: "0.12.1"
88
tekton.dev/tags: release
9+
test: "scott"
910
spec:
1011
description: >-
1112
Tekton task to collect data from release resources and verify that they do not contain any

0 commit comments

Comments
 (0)