Skip to content

Commit e923203

Browse files
committed
Add wile loop to wait for readiness
1 parent 6ece3fe commit e923203

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

9.0.x/pipeline.yaml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,33 @@ spec:
164164
oc patch configmap/pipeline-output -p '{"data":{"Status":"Deployment Pipeline completed to install mas core."}}'
165165
tasks:
166166
- name: check-container-registry
167-
taskSpec:
168-
steps:
169-
- name: check-registry
170-
image: quay.io/openshift/origin-cli:4.10
171-
script: |
172-
#!/usr/bin/env bash
167+
params:
168+
- name: SCRIPT
169+
value: |
170+
status=$(oc get config -o jsonpath='{.items[0].status.conditions[?(@.type=="Available")].reason}')
173171
174-
# Get the status of the ImageRegistry resource
175-
status=$(oc get config -o jsonpath='{.items[0].status.conditions[?(@.type=="Available")].reason}')
172+
TIMEOUT_SECONDS=300
173+
while [[ "$status" != "Ready" ]] && [[ $SECONDS -lt $TIMEOUT_SECONDS ]]; do
174+
echo "OpenShift Container Registry is not ready. Current status: $status"
176175
177-
if [[ "$status" == "Ready" ]]; then
178-
echo "OpenShift Container Registry is ready"
179-
exit 0
180-
else
181-
echo "OpenShift Container Registry is not ready. Reason: $status"
182-
oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"storage":{"emptyDir":{}}}}'
183-
oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"managementState":"Managed"}}'
184-
fi
176+
# Apply the patch commands
177+
oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"storage":{"emptyDir":{}}}}'
178+
oc patch config.imageregistry.operator.openshift.io/cluster --type=merge -p '{"spec":{"managementState":"Managed"}}'
179+
180+
# Check status after a short delay to avoid overwhelming the server
181+
sleep 10
182+
183+
# Update status
184+
status=$(oc get config -o jsonpath='{.items[0].status.conditions[?(@.type=="Available")].reason}')
185+
done
185186
187+
if [[ "$status" == "Ready" ]]; then
188+
echo "OpenShift Container Registry is ready"
186189
exit 0
190+
else
191+
echo "OpenShift Container Registry failed to become ready after $TIMEOUT_SECONDS seconds." >&2
192+
exit 1
193+
fi
187194
- name: get-ibm-entitlement-key
188195
when:
189196
- input: "$(params.ibm-entitlement-key)"

0 commit comments

Comments
 (0)