From 9a04668dad477f05129f88e69c087534e82fe5b5 Mon Sep 17 00:00:00 2001 From: Richard Su Date: Fri, 19 Dec 2025 15:53:56 -0600 Subject: [PATCH] WIP: Add support for passing pre-mirrored images to appliance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add AGENT_OVE_BUILD_METHOD to control OVE ISO build method (script vs container) - Prepare registry directory structure for appliance in 04_agent_prepare_release.sh - Update 06_agent_create_cluster.sh to support both build methods - Both methods now extract agent-iso-builder source and pass mirror-path arguments 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-by: Claude Sonnet 4.5 --- agent/04_agent_prepare_release.sh | 52 ++++++++++++++++++++++++------- agent/06_agent_create_cluster.sh | 51 +++++++++++++++++++++++------- agent/common.sh | 2 ++ 3 files changed, 82 insertions(+), 23 deletions(-) diff --git a/agent/04_agent_prepare_release.sh b/agent/04_agent_prepare_release.sh index 413666e8b..6198b8c0e 100755 --- a/agent/04_agent_prepare_release.sh +++ b/agent/04_agent_prepare_release.sh @@ -13,9 +13,46 @@ source $SCRIPTDIR/agent/common.sh source $SCRIPTDIR/ocp_install_env.sh source $SCRIPTDIR/oc_mirror.sh -# Temporarily skip preparing the custom local release in case of OVE ISO -if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then - exit 0 +early_deploy_validation +write_pull_secret + +# Release mirroring could be required by the subsequent steps +# even if the current one will be skipped +if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then + setup_release_mirror +fi + +# Prepare registry directory for appliance if using ISO_NO_REGISTRY +if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then + if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then + echo "Preparing registry directory structure for appliance..." + + # Create the cache directory structure expected by appliance + # Appliance expects: mirror-path/cache/ (ISO output) + # Appliance will read registry data directly from mirror-path/data + + # Extract version from release image to create cache subdirectory + # Appliance creates cache dir in format: cache/- + VERSION=$(skopeo inspect --authfile ${PULL_SECRET_FILE} docker://${OPENSHIFT_RELEASE_IMAGE} | jq -r '.Labels["io.openshift.release"]') + ARCH=$(uname -m) + CACHE_SUBDIR="${VERSION}-${ARCH}" + mkdir -p ${REGISTRY_DIR}/cache/${CACHE_SUBDIR} + + # Copy YAML files and mapping.txt to registry directory so appliance can find them + if [[ -d ${WORKING_DIR}/working-dir ]]; then + cp -r ${WORKING_DIR}/working-dir ${REGISTRY_DIR}/ + fi + + # Copy results directory containing mapping.txt + for results_dir in ${WORKING_DIR}/results-*; do + if [[ -d "$results_dir" ]]; then + cp -r "$results_dir" ${REGISTRY_DIR}/ + fi + done + + echo "Registry directory prepared for appliance" + exit 0 + fi fi # To replace an image entry in the openshift release image, set _LOCAL_REPO so that: @@ -34,15 +71,6 @@ fi # export ASSISTED_SERVICE_DOCKERFILE=Dockerfile.assisted-service.ocp # export ASSISTED_SERVICE_IMAGE=agent-installer-api-server -early_deploy_validation -write_pull_secret - -# Release mirroring could be required by the subsequent steps -# even if the current one will be skipped -if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then - setup_release_mirror -fi - function build_local_release() { # Sanity checks if [[ -z "${MIRROR_IMAGES}" || "${MIRROR_IMAGES,,}" == "false" ]]; then diff --git a/agent/06_agent_create_cluster.sh b/agent/06_agent_create_cluster.sh index 5455baf33..23a63bd45 100755 --- a/agent/06_agent_create_cluster.sh +++ b/agent/06_agent_create_cluster.sh @@ -85,23 +85,45 @@ function create_config_image() { function create_agent_iso_no_registry() { local asset_dir=${1} - AGENT_ISO_BUILDER_IMAGE=$(getAgentISOBuilderImage) - - id=$(podman create --pull always --authfile "${PULL_SECRET_FILE}" "${AGENT_ISO_BUILDER_IMAGE}") && podman cp "${id}":/src "${asset_dir}" && podman rm "${id}" - # Update release_info.json as its needed by CI tests save_release_info ${OPENSHIFT_RELEASE_IMAGE} ${OCP_DIR} + # Temporarily use custom agent-iso-builder image + AGENT_ISO_BUILDER_IMAGE="quay.io/rwsu1/agent-iso-builder:dev-scripts" + + # Get agent-iso-builder source from container + id=$(podman create --pull always --authfile "${PULL_SECRET_FILE}" "${AGENT_ISO_BUILDER_IMAGE}") && podman cp "${id}":/src "${asset_dir}" && podman rm "${id}" + # Create agent ISO without registry a.k.a. OVE ISO pushd . cd "${asset_dir}"/src - # Build the ISO in the container image - make build-ove-iso-container PULL_SECRET_FILE="${PULL_SECRET_FILE}" RELEASE_IMAGE_URL="${OPENSHIFT_RELEASE_IMAGE}" ARCH=${ARCH} - # Retrieve ISO from container - ./hack/iso-from-container.sh - local iso_name="agent-ove.${ARCH}.iso" - echo "Moving ${iso_name} to ${asset_dir}" - mv ./output-iso/${iso_name} "${asset_dir}" + + # Prepare mirror path arguments if MIRROR_IMAGES is enabled + local mirror_path_arg="" + if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then + echo "Using pre-mirrored images from ${REGISTRY_DIR}" + mirror_path_arg="--mirror-path ${REGISTRY_DIR}" + fi + + if [[ "${AGENT_OVE_BUILD_METHOD}" == "script" ]]; then + # Use the legacy build-ove-image.sh script + ./hack/build-ove-image.sh --pull-secret-file "${PULL_SECRET_FILE}" --release-image-url "${OPENSHIFT_RELEASE_IMAGE}" --ssh-key-file "${SSH_KEY_FILE}" --dir "${asset_dir}" ${mirror_path_arg} + else + # Use container-based build (default) + # Build the ISO in the container image + # Convert mirror path argument to make variable format + local mirror_args="" + if [[ ! -z "${mirror_path_arg}" ]]; then + mirror_args="MIRROR_PATH=${REGISTRY_DIR}" + fi + make build-ove-iso-container PULL_SECRET_FILE="${PULL_SECRET_FILE}" RELEASE_IMAGE_URL="${OPENSHIFT_RELEASE_IMAGE}" ARCH=${ARCH} ${mirror_args} + # Retrieve ISO from container + ./hack/iso-from-container.sh + local iso_name="agent-ove.${ARCH}.iso" + echo "Moving ${iso_name} to ${asset_dir}" + mv ./output-iso/${iso_name} "${asset_dir}" + fi + rm -rf "${asset_dir}"/src popd } @@ -639,6 +661,13 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in cleanup_diskspace_agent_iso_noregistry ${asset_dir} fi + # Clean up registry data to save disk space after ISO is created + if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then + echo "Cleaning up registry data at ${REGISTRY_DIR} to save disk space" + sudo rm -rf ${REGISTRY_DIR}/data + echo "Registry data cleanup complete" + fi + attach_agent_iso_no_registry master $NUM_MASTERS attach_agent_iso_no_registry worker $NUM_WORKERS attach_agent_iso_no_registry arbiter $NUM_ARBITERS diff --git a/agent/common.sh b/agent/common.sh index 8b7c69083..e37e0ed14 100644 --- a/agent/common.sh +++ b/agent/common.sh @@ -15,6 +15,8 @@ export AGENT_ROOT_DEVICE_HINTS=${AGENT_ROOT_DEVICE_HINTS:-""} export AGENT_BM_HOSTS_IN_INSTALL_CONFIG=${AGENT_BM_HOSTS_IN_INSTALL_CONFIG:-"false"} export AGENT_MINIMAL_ISO=${AGENT_MINIMAL_ISO:-"false"} +# OVE ISO build method: "script" uses build-ove-image.sh, "container" uses Dockerfile-based build +export AGENT_OVE_BUILD_METHOD=${AGENT_OVE_BUILD_METHOD:-"container"} export BOND_CONFIG=${BOND_CONFIG:-"none"}