Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions agent/04_agent_prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/<version-arch> (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>-<arch>
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 <ENTRYNAME>_LOCAL_REPO so that:
Expand All @@ -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
Expand Down
51 changes: 40 additions & 11 deletions agent/06_agent_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions agent/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down