Skip to content

Commit 05ab087

Browse files
stuggiclaude
andcommitted
Fix timing issues and hardcoded CR name in restore script
**Timing fix:** - Add 10-second sleep after creating OpenStackControlPlane CR - Prevents "NotFound" error when oc wait tries to access the resource before API server fully registers it **Dynamic CR name handling:** - Extract actual CR name from backup instead of hardcoding "openstack" - Supports any CR name (openstack, controlplane, openstack-prod, etc.) - Update all oc commands to use ${CTLPLANE_NAME} variable: - oc wait --for=condition=InfrastructureReady - oc annotate (remove deployment-stage annotation) - oc get openstackcontrolplane - oc wait --for=condition=Ready This fixes restore failures when: 1. API server hasn't registered the CR yet (race condition) 2. Backup contains CR with name other than "openstack" Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent f0f02a4 commit 05ab087

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

docs/dev/restore-openstack-ctlplane.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ CTLPLANE_STAGED=$(mktemp)
429429
jq '.items[0].metadata.annotations["core.openstack.org/deployment-stage"] = "infrastructure-only"' \
430430
openstackcontrolplane-backup.json > ${CTLPLANE_STAGED}
431431

432+
# Get the actual CR name from the backup
433+
CTLPLANE_NAME=$(jq -r '.items[0].metadata.name' openstackcontrolplane-backup.json)
434+
echo "OpenStackControlPlane CR name: ${CTLPLANE_NAME}"
435+
432436
oc apply -f ${CTLPLANE_STAGED} -n ${NAMESPACE}
433437
rm -f ${CTLPLANE_STAGED}
434438
echo "✓ OpenStackControlPlane CR restored with staged deployment annotation"
@@ -438,13 +442,17 @@ echo "Waiting for infrastructure to be ready..."
438442
echo "This may take several minutes..."
439443
echo ""
440444

445+
echo "Waiting for API server to register the resource..."
446+
sleep 10
447+
echo ""
448+
441449
echo "Waiting for InfrastructureReady condition..."
442-
if oc wait --for=condition=InfrastructureReady openstackcontrolplane/openstack -n ${NAMESPACE} --timeout=20m; then
450+
if oc wait --for=condition=InfrastructureReady openstackcontrolplane/${CTLPLANE_NAME} -n ${NAMESPACE} --timeout=20m; then
443451
echo "✓ Infrastructure is ready!"
444452
else
445453
echo "Warning: Timeout waiting for InfrastructureReady condition"
446454
echo "Check status manually:"
447-
echo " oc get openstackcontrolplane openstack -n ${NAMESPACE} -o jsonpath='{.status.conditions}'"
455+
echo " oc get openstackcontrolplane ${CTLPLANE_NAME} -n ${NAMESPACE} -o jsonpath='{.status.conditions}'"
448456
fi
449457
echo ""
450458

@@ -485,7 +493,7 @@ if [ "${DB_RESTORE_CONFIRM}" != "yes" ]; then
485493

486494
if [ "${SKIP_DB_CONFIRM}" != "yes" ]; then
487495
echo "Aborting. Restore databases and then resume with:"
488-
echo " oc annotate openstackcontrolplane openstack -n ${NAMESPACE} core.openstack.org/deployment-stage-"
496+
echo " oc annotate openstackcontrolplane ${CTLPLANE_NAME} -n ${NAMESPACE} core.openstack.org/deployment-stage-"
489497
popd > /dev/null
490498
rm -rf ${WORK_DIR}
491499
exit 1
@@ -611,14 +619,14 @@ if [ "${RESUME_CONFIRM}" != "yes" ]; then
611619
echo ""
612620
echo "⚠️ Deployment is still paused with annotation."
613621
echo "To resume later, run:"
614-
echo " oc annotate openstackcontrolplane openstack -n ${NAMESPACE} core.openstack.org/deployment-stage-"
622+
echo " oc annotate openstackcontrolplane ${CTLPLANE_NAME} -n ${NAMESPACE} core.openstack.org/deployment-stage-"
615623
popd > /dev/null
616624
rm -rf ${WORK_DIR}
617625
exit 0
618626
fi
619627

620628
echo "Removing deployment-stage annotation..."
621-
oc annotate openstackcontrolplane openstack -n ${NAMESPACE} \
629+
oc annotate openstackcontrolplane ${CTLPLANE_NAME} -n ${NAMESPACE} \
622630
core.openstack.org/deployment-stage-
623631
echo "✓ Annotation removed, deployment resuming"
624632
echo ""
@@ -629,17 +637,17 @@ echo ""
629637
sleep 5
630638

631639
echo "Current OpenStackControlPlane status:"
632-
oc get openstackcontrolplane openstack -n ${NAMESPACE}
640+
oc get openstackcontrolplane ${CTLPLANE_NAME} -n ${NAMESPACE}
633641
echo ""
634642

635643
echo "Waiting for OpenStackControlPlane to become Ready..."
636644
echo "This may take 10-30 minutes depending on the deployment size..."
637-
if oc wait --for=condition=Ready openstackcontrolplane/openstack -n ${NAMESPACE} --timeout=30m; then
645+
if oc wait --for=condition=Ready openstackcontrolplane/${CTLPLANE_NAME} -n ${NAMESPACE} --timeout=30m; then
638646
echo "✓ OpenStackControlPlane is Ready!"
639647
else
640648
echo "Warning: Timeout waiting for Ready condition"
641649
echo "Deployment may still be in progress. Check manually:"
642-
echo " oc get openstackcontrolplane openstack -n ${NAMESPACE} --watch"
650+
echo " oc get openstackcontrolplane ${CTLPLANE_NAME} -n ${NAMESPACE} --watch"
643651
fi
644652
echo ""
645653

0 commit comments

Comments
 (0)