Skip to content

Commit 1244c92

Browse files
committed
fix(ci): add error handling and wait mechanism for Backstage resource and deployment
Enhanced the `enable_orchestrator_plugins_op` function to include error handling for the Backstage resource check, logging an error if the resource is not found. Additionally, implemented a wait mechanism in the `deploy_rhdh_operator` function to ensure the Backstage deployment is created by the operator, with appropriate logging for success and warnings for potential asynchronous creation.
1 parent 6103ef2 commit 1244c92

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

.ibm/pipelines/install-methods/operator.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ deploy_rhdh_operator() {
7575
log::info "Applying Backstage CR from: $backstage_crd_path"
7676
log::debug "$rendered_yaml"
7777
echo "$rendered_yaml" | oc apply -f - -n "$namespace"
78+
79+
# Wait for the operator to create the Backstage deployment
80+
log::info "Waiting for operator to create Backstage deployment..."
81+
local max_wait=60 # Wait up to 5 minutes for deployment to be created
82+
local waited=0
83+
while [[ $waited -lt $max_wait ]]; do
84+
if oc get deployment -n "$namespace" --no-headers 2> /dev/null | grep -q "backstage-"; then
85+
log::success "Backstage deployment created by operator"
86+
return 0
87+
fi
88+
log::debug "Waiting for deployment to be created... ($waited/$max_wait checks)"
89+
sleep 5
90+
waited=$((waited + 1))
91+
done
92+
93+
log::warn "Deployment not found after ${max_wait} checks, but continuing (may be created asynchronously)"
94+
return 0
7895
}
7996

8097
delete_rhdh_operator() {

.ibm/pipelines/utils.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,10 @@ enable_orchestrator_plugins_op() {
16841684
log::info "Waiting for backstage resource to exist in namespace: $namespace"
16851685

16861686
# Wait for backstage resource to exist
1687-
wait_for_backstage_resource "$namespace"
1687+
if ! wait_for_backstage_resource "$namespace"; then
1688+
log::error "Failed to find backstage resource in namespace: $namespace"
1689+
return 1
1690+
fi
16881691

16891692
log::info "Backstage resource is ready with orchestrator plugins configured"
16901693
}

0 commit comments

Comments
 (0)