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/<release> 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/<release> are properly
      populated.
    - Verify subcloud is installed using prestaged data from
      /opt/platform-backup/<release>
    - 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 <kyle.macleod@windriver.com>
Change-Id: I973f4704eae09634a0c3fe2f7fbc31ac1835fcf8
This commit is contained in:
Kyle MacLeod 2023-10-12 11:16:59 -04:00
parent 61e01d2000
commit e81d0bf4e7
2 changed files with 29 additions and 15 deletions

View File

@ -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

View File

@ -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