From 37fca0490ead28a22dffed2d02ebd953155d0c21 Mon Sep 17 00:00:00 2001 From: Gustavo Herzmann Date: Tue, 22 Jul 2025 10:19:35 -0300 Subject: [PATCH] Update prestaged ostree-repo location for subcloud factory restore This commit checks the auto_restore_mode during subcloud installation, and if it is set to "factory", it updates the prestaged ostree_repo location to point to the factory backup directory at /opt/platform-backup/factory//ostree_repo. Test Plan: 01. PASS - Run a factory subcloud restore and verify that it uses the prestaged ostree_repo inside the subcloud factory backup directory. 02. PASS - Run a non-factory subcloud restore and verify that it uses the prestaged ostree_repo from the default location. Story: 2011454 Task: 52563 Change-Id: I41a683c9ed88f9b8ec68a2f4139b650d802901ca Signed-off-by: Gustavo Herzmann --- kickstart/files/miniboot.cfg | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/kickstart/files/miniboot.cfg b/kickstart/files/miniboot.cfg index c85ec5e8..cd61c235 100644 --- a/kickstart/files/miniboot.cfg +++ b/kickstart/files/miniboot.cfg @@ -2125,6 +2125,27 @@ else backup_mount=/tmp/platform-backup backup_mount_release="${backup_mount}"/xxxPLATFORM_RELEASExxx + # If this install is part of a factory auto-restore operation, the + # prestaged ostree_repo is inside the factory backup directory + if [[ "${include_paths}" == *"auto-restore"* ]]; then + ilog "Auto-restore detected, mounting instboot to verify auto-restore mode..." + mkdir -p /instboot + if mount /dev/disk/by-label/instboot /instboot 2>/dev/null; then + ilog "Successfully mounted /dev/disk/by-label/instboot to /instboot" + else + report_failure_with_msg "Failed to mount /dev/disk/by-label/instboot to /instboot" + fi + + restore_config="/instboot/auto-restore/backup_restore_values.yml" + auto_restore_mode=$(grep "^auto_restore_mode:" "$restore_config" 2>/dev/null | sed 's/auto_restore_mode: *//' | tr -d '"' | tr -d "'") + ilog "auto_restore_mode: '$auto_restore_mode'" + if [[ "$auto_restore_mode" == "factory" ]]; then + backup_mount_release="${backup_mount}/factory/xxxPLATFORM_RELEASExxx" + ilog "Set backup_mount_release to factory path: $backup_mount_release" + fi + umount /instboot + fi + ilog "Temporary backup mount: ${backup_mount}, release: ${backup_mount_release}" mkdir -p "${backup_mount}" mount "${backup_device}" "${backup_mount}" 2>/dev/null @@ -2177,6 +2198,12 @@ else # Check if auto-restore is enabled, if so, prestaged ostree_repo is mandatory if [[ "${include_paths}" == *"auto-restore"* ]]; then if [ ! -e "${backup_mount_release}/ostree_repo" ] || [ -n "${local_repo_check_fail}" ]; then + if [ -d "${backup_mount_release}" ]; then + elog "Contents of backup_mount_release (${backup_mount_release}):" + elog "$(ls -la "${backup_mount_release}" 2>/dev/null || echo "Failed to list directory contents")" + else + elog "Directory ${backup_mount_release} does not exist" + fi report_failure_with_msg "ostree_repo must be prestaged for auto-restore operation" fi fi