From e81d0bf4e7f6c3ff0c814ac48b923dc8d889df03 Mon Sep 17 00:00:00 2001 From: Kyle MacLeod Date: Thu, 12 Oct 2023 11:16:59 -0400 Subject: [PATCH] Prestaged ISO: copy ostree_repo to versioned platform-backup This commit applies to the prestaged ISO install. The kickstart.cfg is updated to copy the prestaged ostree_repo into release-specific /opt/platform-backup/ location. A minor change is also included in miniboot.cfg to sync the patching metadata for prepatched ISOs. This fills a potential hole in the patching metadata sync behaviour identified during testing. Normally the patching metadata is synchronized from the system controller down to the subcloud. For the prestaged ISO case, this change is necessary to ensure the patching metadata is seeded from the prepatched ISO created via gen-prestaged-iso.sh. Test Plan PASS: - Build prestaged ISO, including container images and a patch - Install subcloud using prestaged ISO - Verify contents of /opt/platform-backup/ are properly populated. - Verify subcloud is installed using prestaged data from /opt/platform-backup/ - Verify that included container images are installed - Build prestaged ISO using a pre-patched ISO. Install subcloud, ensure that patching metadata is properly synchronized on installation. Out of scope failure: - A new bug to be raised for the following: - Verify that the included patch is installed on the subcloud - It appears that this has never worked in Debian. The --patch option makes sense for a Debian installation, since the patches are contained in ostree commits. To fully support this functionality we need to implement a new mechanism to do a sw-patch upload and apply at some point during the installation. - Support for the gen-prestaged-iso.sh --patch option will be added in a future commit Closes-Bug: 2039282 Signed-off-by: Kyle MacLeod Change-Id: I973f4704eae09634a0c3fe2f7fbc31ac1835fcf8 --- kickstart/files/kickstart.cfg | 34 ++++++++++++++++++++-------------- kickstart/files/miniboot.cfg | 10 +++++++++- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/kickstart/files/kickstart.cfg b/kickstart/files/kickstart.cfg index 68f11851..2e948d25 100644 --- a/kickstart/files/kickstart.cfg +++ b/kickstart/files/kickstart.cfg @@ -2876,12 +2876,13 @@ if [ "${controller}" = true ] ; then # Check if this is a prestage iso.If yes, then # copy the ostree_repo to the backup directory. if is_prestage -eq 0 ; then - ilog "Prestage operation: copying repo to /opt/platform-backup" - staging_dir=platform-backup - backup_device=/dev/disk/by-partlabel/platform_backup - backup_mount=/tmp/${staging_dir} + ilog "Prestage operation: copying repo to /opt/platform-backup/${sw_release}" - ilog "Temporary backup mount is ${backup_mount}" + backup_device=/dev/disk/by-partlabel/platform_backup + backup_mount=/tmp/platform-backup + backup_mount_release="${backup_mount}/${sw_release}" + + ilog "Temporary backup mount: ${backup_mount}, release: ${backup_mount_release}" mkdir -p "${backup_mount}" mount "${backup_device}" "${backup_mount}" rc=$? @@ -2889,27 +2890,32 @@ if [ "${controller}" = true ] ; then report_failure_with_msg "Unable to mount ${backup_device} on ${backup_mount} [rc=${rc}]" fi - ilog "Copying repo to ${backup_mount}" - cp -a ${repo} ${backup_mount} + ilog "Copying repo to ${backup_mount_release}" + mkdir "${backup_mount_release}" rc=$? if [ ${rc} -ne 0 ]; then - report_failure_with_msg "Unable to copy repo to /opt/platform-backup [rc=${rc}]" + report_failure_with_msg "Unable to create ${backup_mount_release} directory [rc=${rc}]" + fi + cp -a "${repo}" "${backup_mount_release}" + rc=$? + if [ ${rc} -ne 0 ]; then + report_failure_with_msg "Unable to copy repo to /opt/platform-backup/${sw_release} [rc=${rc}]" fi # The summary file is not transferred on an ostree pull, so we need to # regenerate the checksum here based on the new local repo contents - ilog "Calculating new checksum for prestaged ${backup_mount}/ostree_repo" - pushd "${backup_mount}" > /dev/null + ilog "Calculating new checksum for prestaged ${backup_mount_release}/ostree_repo" + pushd "${backup_mount_release}" > /dev/null find ostree_repo -type f -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1; }' > .ostree_repo_checksum ilog "Calculated checksum: $(cat .ostree_repo_checksum)" popd > /dev/null if [ -e "/instboot/opt/platform-backup/${sw_release}" ]; then - ilog "Copying images and patches to ${backup_mount}" - cp -a /instboot/opt/platform-backup/${sw_release} ${backup_mount} + ilog "Copying images and patches to ${backup_mount_release}" + rsync -a /instboot/opt/platform-backup/${sw_release}/ ${backup_mount_release} rc=$? if [ ${rc} -ne 0 ]; then - report_failure_with_msg "Unable to copy images from /instboot to /opt/platform-backup [rc=${rc}]" + report_failure_with_msg "Unable to copy images from /instboot to /opt/platform-backup/${sw_release} [rc=${rc}]" fi fi @@ -3203,7 +3209,7 @@ if [ -e "/instboot/ks-addon.cfg" ]; then source /instboot/ks-addon.cfg rc=$? if [ "${rc}" -ne 0 ]; then - ilog "Addon script ks-addon.cfg exited with [rc=${rc}]" + ilog "Addon script ks-addon.cfg exited with [rc=${rc}]" fi fi diff --git a/kickstart/files/miniboot.cfg b/kickstart/files/miniboot.cfg index e250dbe7..136a953e 100644 --- a/kickstart/files/miniboot.cfg +++ b/kickstart/files/miniboot.cfg @@ -2936,10 +2936,18 @@ if [ "${controller}" = true ] ; then # This fetch is only needed once because the repo is stored in /var set_variable "ostree_repo_fetched" + # If the miniboot ISO contains a patches directory + if [ -d "/instboot/patches" ]; then + ilog "Prepatched iso" + ilog "Creating patching metadata directories" + mkdir -p ${IMAGE_ROOTFS}/var/rootdirs/opt/patching/metadata/{committed,available,applied} + cp -a /instboot/patches/* ${IMAGE_ROOTFS}/var/rootdirs/opt/patching/metadata/committed/ + fi + # copy efi.img to /var/pxeboot to enable duplex/multinode subclouds cp -a /instboot/efi.img ${pxedir} rc=$? - if [ rc -ne 0 ]; then + if [ ${rc} -ne 0 ]; then elog "Failed to copy efi.img to ${pxedir}" fi