Skip to content

Commit 27eaaa3

Browse files
committed
AGENT-1193: Add mirror-path and registry-cert support for OVE ISO builds
Add support for using pre-mirrored images and custom registry certificates when building OVE ISOs, enabling disconnected deployments with custom registries. Changes for mirror-path: - Pass --mirror-path to build-ove-image.sh when MIRROR_IMAGES is enabled - Appliance skips oc-mirror and uses pre-mirrored images when --mirror-path is provided Changes for registry-cert: - Add --registry-cert parameter for custom registry TLS certificates - Support both script build method (faster for development/debugging) and container build method - Use unified mechanism across both build methods - Convert to REGISTRY_CERT make variable for containerized builds Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5901c75 commit 27eaaa3

5 files changed

Lines changed: 111 additions & 24 deletions

File tree

agent/04_agent_prepare_release.sh

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,43 @@ source $SCRIPTDIR/agent/common.sh
1313
source $SCRIPTDIR/ocp_install_env.sh
1414
source $SCRIPTDIR/oc_mirror.sh
1515

16-
# Temporarily skip preparing the custom local release in case of OVE ISO
17-
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
18-
exit 0
16+
early_deploy_validation
17+
write_pull_secret
18+
19+
# Release mirroring could be required by the subsequent steps
20+
# even if the current one will be skipped
21+
if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then
22+
setup_release_mirror
23+
fi
24+
25+
# Prepare registry directory for appliance if using ISO_NO_REGISTRY
26+
if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" && "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
27+
echo "Preparing registry directory structure for appliance..."
28+
29+
# Create the cache directory structure expected by appliance
30+
# Appliance expects: mirror-path/cache/<version-arch> (ISO output)
31+
# Appliance will read registry data directly from mirror-path/data
32+
33+
# Extract version from release image to create cache subdirectory
34+
# Appliance creates cache dir in format: cache/<version>-<arch>
35+
VERSION=$(skopeo inspect --authfile ${PULL_SECRET_FILE} docker://${OPENSHIFT_RELEASE_IMAGE} | jq -r '.Labels["io.openshift.release"]')
36+
ARCH=$(uname -m)
37+
CACHE_SUBDIR="${VERSION}-${ARCH}"
38+
mkdir -p ${REGISTRY_DIR}/cache/${CACHE_SUBDIR}
39+
40+
# Copy YAML files and mapping.txt to registry directory so appliance can find them
41+
if [[ -d ${WORKING_DIR}/working-dir ]]; then
42+
cp -r ${WORKING_DIR}/working-dir ${REGISTRY_DIR}/
43+
fi
44+
45+
# Copy results directory containing mapping.txt
46+
for results_dir in ${WORKING_DIR}/results-*; do
47+
if [[ -d "$results_dir" ]]; then
48+
cp -r "$results_dir" ${REGISTRY_DIR}/
49+
fi
50+
done
51+
52+
echo "Registry directory prepared for appliance"
1953
fi
2054

2155
# To replace an image entry in the openshift release image, set <ENTRYNAME>_LOCAL_REPO so that:
@@ -34,15 +68,6 @@ fi
3468
# export ASSISTED_SERVICE_DOCKERFILE=Dockerfile.assisted-service.ocp
3569
# export ASSISTED_SERVICE_IMAGE=agent-installer-api-server
3670

37-
early_deploy_validation
38-
write_pull_secret
39-
40-
# Release mirroring could be required by the subsequent steps
41-
# even if the current one will be skipped
42-
if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then
43-
setup_release_mirror
44-
fi
45-
4671
function build_local_release() {
4772
# Sanity checks
4873
if [[ -z "${MIRROR_IMAGES}" || "${MIRROR_IMAGES,,}" == "false" ]]; then

agent/06_agent_create_cluster.sh

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,66 @@ function create_config_image() {
8585
function create_agent_iso_no_registry() {
8686
local asset_dir=${1}
8787

88+
# Update release_info.json as its needed by CI tests
89+
save_release_info ${OPENSHIFT_RELEASE_IMAGE} ${OCP_DIR}
90+
8891
AGENT_ISO_BUILDER_IMAGE=$(getAgentISOBuilderImage)
8992

93+
# Get agent-iso-builder source from container
9094
id=$(podman create --pull always --authfile "${PULL_SECRET_FILE}" "${AGENT_ISO_BUILDER_IMAGE}") && podman cp "${id}":/src "${asset_dir}" && podman rm "${id}"
9195

92-
# Update release_info.json as its needed by CI tests
93-
save_release_info ${OPENSHIFT_RELEASE_IMAGE} ${OCP_DIR}
94-
9596
# Create agent ISO without registry a.k.a. OVE ISO
9697
pushd .
9798
cd "${asset_dir}"/src
98-
# Build the ISO in the container image
99-
make build-ove-iso-container PULL_SECRET_FILE="${PULL_SECRET_FILE}" RELEASE_IMAGE_URL="${OPENSHIFT_RELEASE_IMAGE}" ARCH=${ARCH}
100-
# Retrieve ISO from container
101-
./hack/iso-from-container.sh
102-
local iso_name="agent-ove.${ARCH}.iso"
103-
echo "Moving ${iso_name} to ${asset_dir}"
104-
mv ./output-iso/${iso_name} "${asset_dir}"
99+
100+
# Prepare mirror path and registry cert arguments if MIRROR_IMAGES is enabled
101+
local mirror_path_arg=""
102+
local registry_cert_arg=""
103+
if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then
104+
echo "Using pre-mirrored images from ${REGISTRY_DIR}"
105+
mirror_path_arg="--mirror-path ${REGISTRY_DIR}"
106+
107+
# Check if using a custom registry (not upstream quay.io or registry.ci.openshift.org)
108+
if [[ ! "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" =~ quay\.io ]] && [[ ! "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" =~ registry\.ci\.openshift\.org ]]; then
109+
if [[ -f "${REGISTRY_DIR}/certs/${REGISTRY_CRT}" ]]; then
110+
# Pass certificate path as argument (used by both script and container methods)
111+
registry_cert_arg="--registry-cert ${REGISTRY_DIR}/certs/${REGISTRY_CRT}"
112+
fi
113+
fi
114+
fi
115+
116+
# Determine which release image to use
117+
local release_image_url="${OPENSHIFT_RELEASE_IMAGE}"
118+
if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then
119+
release_image_url="${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}"
120+
echo "Using mirrored release image: ${release_image_url}"
121+
else
122+
echo "Using upstream release image: ${release_image_url}"
123+
fi
124+
125+
if [[ "${AGENT_ISO_NO_REGISTRY_BUILD_METHOD}" == "script" ]]; then
126+
# Use the legacy build-ove-image.sh script
127+
./hack/build-ove-image.sh --pull-secret-file "${PULL_SECRET_FILE}" --release-image-url "${release_image_url}" --ssh-key-file "${SSH_KEY_FILE}" --dir "${asset_dir}" ${mirror_path_arg} ${registry_cert_arg}
128+
else
129+
# Use container-based build (default)
130+
# Build the ISO in the container image
131+
# Convert mirror path and registry cert arguments to make variable format
132+
local mirror_args=""
133+
if [[ ! -z "${mirror_path_arg}" ]]; then
134+
mirror_args="MIRROR_PATH=${REGISTRY_DIR}"
135+
fi
136+
local registry_cert_make_arg=""
137+
if [[ ! -z "${registry_cert_arg}" ]]; then
138+
registry_cert_make_arg="REGISTRY_CERT=${REGISTRY_DIR}/certs/${REGISTRY_CRT}"
139+
fi
140+
make build-ove-iso-container PULL_SECRET_FILE="${PULL_SECRET_FILE}" RELEASE_IMAGE_URL="${release_image_url}" ARCH=${ARCH} ${mirror_args} ${registry_cert_make_arg}
141+
# Retrieve ISO from container
142+
./hack/iso-from-container.sh
143+
local iso_name="agent-ove.${ARCH}.iso"
144+
echo "Moving ${iso_name} to ${asset_dir}"
145+
mv ./output-iso/${iso_name} "${asset_dir}"
146+
fi
147+
105148
rm -rf "${asset_dir}"/src
106149
popd
107150
}
@@ -639,6 +682,13 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in
639682
cleanup_diskspace_agent_iso_noregistry ${asset_dir}
640683
fi
641684

685+
# Clean up registry data to save disk space after ISO is created
686+
if [[ ! -z "${MIRROR_IMAGES}" && "${MIRROR_IMAGES,,}" != "false" ]]; then
687+
echo "Cleaning up registry data at ${REGISTRY_DIR} to save disk space"
688+
sudo rm -rf ${REGISTRY_DIR}/data
689+
echo "Registry data cleanup complete"
690+
fi
691+
642692
attach_agent_iso_no_registry master $NUM_MASTERS
643693
attach_agent_iso_no_registry worker $NUM_WORKERS
644694
attach_agent_iso_no_registry arbiter $NUM_ARBITERS

agent/common.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export AGENT_ROOT_DEVICE_HINTS=${AGENT_ROOT_DEVICE_HINTS:-""}
1515
export AGENT_BM_HOSTS_IN_INSTALL_CONFIG=${AGENT_BM_HOSTS_IN_INSTALL_CONFIG:-"false"}
1616

1717
export AGENT_MINIMAL_ISO=${AGENT_MINIMAL_ISO:-"false"}
18+
# OVE ISO build method: "script" uses build-ove-image.sh, "container" uses Dockerfile-based build
19+
export AGENT_ISO_NO_REGISTRY_BUILD_METHOD=${AGENT_ISO_NO_REGISTRY_BUILD_METHOD:-"container"}
1820

1921
export BOND_CONFIG=${BOND_CONFIG:-"none"}
2022

config_example.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,20 @@ set -x
870870
# AGENT_E2E_TEST_BOOT_MODE is set to ISO_NO_REGISTRY.
871871
# AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV is useful for reclaiming disk space when building agent OVE ISO locally
872872
# by deleting all the files from the working directory, example ocp/ostest/iso_builder except the generated OVE ISO.
873-
# Set to 'true' to enable the cleanup.
873+
# Set to 'true' to enable the cleanup.
874874
# Default behavior (unset or any value other than 'yes') is to skip cleanup.
875875
# Recommended to set to true for local dev/test purposes and unset in CI.
876876
# export AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV=false
877877

878+
# AGENT_ISO_NO_REGISTRY_BUILD_METHOD controls which method is used to build the OVE ISO when
879+
# AGENT_E2E_TEST_BOOT_MODE is set to ISO_NO_REGISTRY.
880+
# Options:
881+
# 'container' (default) - Uses containerized Dockerfile-based build (required for CI/build pipelines)
882+
# 'script' - Uses build-ove-image.sh script directly (faster for local development/debugging)
883+
# The container method is required in CI/build pipeline environments where nested podman is not supported.
884+
# The script method is recommended for local development as it allows faster iteration and easier debugging.
885+
# export AGENT_ISO_NO_REGISTRY_BUILD_METHOD=container
886+
878887
# Specifies the hostname of the node that should be identified and set as the rendezvous node
879888
# during the OVE cluster installation process. This node acts as the bootstrap node in the cluster.
880889
# Accepts only master nodes.

ocp_install_env.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function extract_command() {
5151
cmd="oc"
5252
fi
5353

54-
mv "${extract_dir}/${cmd}" "${outdir}"
54+
mkdir -p "${outdir}"
55+
mv "${extract_dir}/${cmd}" "${outdir}/"
5556
}
5657

5758
# Let's always grab the `oc` from the release we're using.

0 commit comments

Comments
 (0)