From d82594c39cad12bd3c194827d24fb5760f5aa8de Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Fri, 25 Apr 2025 12:06:43 -0400 Subject: [PATCH 1/2] OCPBUGS-55386: Update oc-mirror to use -v2 Use version v2 of oc-mirror. This version has many improvements over v1 but the primary reason for using v2 is that it allows nightly or CI builds to be tested via the release field in the ImageSetConfiguration. Note that oc-mirror is not currently used in any CI tests and has strictly been used for local testing with the agent-based installer. As a result its not necessary to keep backwards compatibility with v1. It's expected that oc-mirror will eventually be used for setting up a mirror for disconnected testing instead of 'oc adm release mirror' since its the most common way to set up mirrors by our customers; 'oc adm release mirror' does not provide for installing additional operators. --- agent/05_agent_configure.sh | 6 +++--- common.sh | 6 ------ oc_mirror.sh | 35 ++++++++++++----------------------- oc_mirror_cleanup.sh | 8 ++------ 4 files changed, 17 insertions(+), 38 deletions(-) diff --git a/agent/05_agent_configure.sh b/agent/05_agent_configure.sh index 019b8e482..d0457b7dc 100755 --- a/agent/05_agent_configure.sh +++ b/agent/05_agent_configure.sh @@ -240,9 +240,9 @@ function get_mirror_info { # output ImageDigestSources, while prior to that it was ImageContentSources sed -n -E '/imageContentSources|imageDigestSources/,/^ *$/p' ${MIRROR_LOG_FILE} | tail -n+2 > ${tmpmirrorinfo} else - results_dir=$(grep ICSP ${WORKING_DIR}/.oc-mirror.log | grep -o 'oc-mirror[^;]*') - sed -ne '/repository/,/---/p' ${WORKING_DIR}/${results_dir}/imageContentSourcePolicy.yaml > ${tmpmirrorinfo} - sed -i '/repositoryDigestMirrors/d;/---/d' ${tmpmirrorinfo} + # Get the mirror config from the idms file generated by oc-mirror + idms_file=${WORKING_DIR}/working-dir/cluster-resources/idms-oc-mirror.yaml + sed -ne '/imageDigestMirrors:$/,/^status:/{/imageDigestMirrors:$/d;/^status:/d;p;}' $idms_file | sed 's/ //' > ${tmpmirrorinfo} fi if [[ ${AGENT_USE_ZTP_MANIFESTS} == true ]]; then diff --git a/common.sh b/common.sh index 40ff90eea..a041399d4 100644 --- a/common.sh +++ b/common.sh @@ -551,12 +551,6 @@ if [[ "${MIRROR_IMAGES,,}" != "false" ]] && [[ "${MIRROR_IMAGES,,}" == "true" || if [[ "${MIRROR_COMMAND}" == "oc-mirror" ]]; then # Use the string that is generated by the output of oc-mirror export LOCAL_IMAGE_URL_SUFFIX="openshift/release-images" - - # set up the channel using the most recent candidate release - pushd ${WORKING_DIR} - release_candidate=`oc-mirror list releases --channel=candidate-${OPENSHIFT_RELEASE_STREAM} | tail -1` - popd - export OPENSHIFT_RELEASE_TAG="${release_candidate}-$(uname -m)" fi # We're going to be using a locally modified release image diff --git a/oc_mirror.sh b/oc_mirror.sh index f00067a43..65623ec52 100755 --- a/oc_mirror.sh +++ b/oc_mirror.sh @@ -78,26 +78,13 @@ function create_file_imageset() { imageset=$1 - latest_release=$(oc-mirror list releases --channel candidate-${OPENSHIFT_RELEASE_STREAM}| tail -n1) - - # Note that the archiveSize defines the maximum size, in GiB, of each file within the image set. - # This must be large enough to include all images in one file for the publish. cat > "${imageset}" << EOF -apiVersion: mirror.openshift.io/v1alpha2 kind: ImageSetConfiguration -archiveSize: 16 -storageConfig: - local: - path: metadata +apiVersion: mirror.openshift.io/v2alpha1 mirror: platform: - architectures: - - "amd64" - channels: - - name: candidate-${OPENSHIFT_RELEASE_STREAM} - minVersion: $latest_release - maxVersion: $latest_release - type: ocp + graph: true + release: $OPENSHIFT_RELEASE_IMAGE additionalImages: - name: registry.redhat.io/ubi8/ubi:latest EOF @@ -105,6 +92,7 @@ EOF } # Mirror the upstream channel directly to the local registry +# Note that this method is only valid with oc mirror v1 function mirror_to_mirror_publish() { # Create imageset containing the local URL and the OCP release to mirror @@ -124,18 +112,16 @@ function mirror_to_file() { config=${1} pushd ${WORKING_DIR} - oc_mirror_dir=$(mktemp --tmpdir -d "oc-mirror-files--XXXXXXXXXX") - _tmpfiles="$_tmpfiles $oc_mirror_dir" - oc-mirror --config ${config} file://${oc_mirror_dir} --ignore-history - archive_file="$(ls ${oc_mirror_dir}/mirror_seq*)" + oc-mirror --v2 --config ${config} file://${WORKING_DIR} popd - } function publish_image() { + config=${1} + pushd ${WORKING_DIR} - oc-mirror --from $archive_file docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT} --dest-skip-tls --skip-metadata-check + oc-mirror --v2 --config ${config} --from file://${WORKING_DIR} docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT} popd } @@ -156,6 +142,9 @@ function setup_oc_mirror() { mirror_to_file $tmpimageset - publish_image + publish_image $tmpimageset + + # remove interim file + rm ${WORKING_DIR}/mirror_*.tar fi } diff --git a/oc_mirror_cleanup.sh b/oc_mirror_cleanup.sh index 202b45fa0..4f3765391 100755 --- a/oc_mirror_cleanup.sh +++ b/oc_mirror_cleanup.sh @@ -14,12 +14,8 @@ if [[ -f "/usr/local/bin/oc-mirror" ]]; then sudo rm "/usr/local/bin/oc-mirror" fi -if [ -f "${WORKING_DIR}/.oc-mirror.log" ]; then - rm "${WORKING_DIR}/.oc-mirror.log" -fi - -if [ -d "${WORKING_DIR}/oc-mirror-workspace" ]; then - rm -rf "${WORKING_DIR}/oc-mirror-workspace" +if [ -d "${WORKING_DIR}/working-dir" ]; then + rm -rf "${WORKING_DIR}/working-dir" fi if [ -d "${WORKING_DIR}/quay-install" ]; then From a1c4b25868804c8c4a2098e1b7506dc68c188c3e Mon Sep 17 00:00:00 2001 From: Richard Su Date: Mon, 5 May 2025 21:41:48 -0500 Subject: [PATCH 2/2] AGENT-1193: Allow openshift-appliance to work with ephemeral payload Re-enable 04_agent_prepare_release.sh with ISO_NO_REGISTRY so that images can be built and placed in the ephemeral release payload and can then be consumed by OpenShift Appliance. --- agent/04_agent_prepare_release.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/agent/04_agent_prepare_release.sh b/agent/04_agent_prepare_release.sh index 413666e8b..ff99f01a0 100755 --- a/agent/04_agent_prepare_release.sh +++ b/agent/04_agent_prepare_release.sh @@ -13,11 +13,6 @@ 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 -fi - # To replace an image entry in the openshift release image, set _LOCAL_REPO so that: # - ENTRYNAME matches an uppercase version of the name in the release image with "-" converted to "_" # - The var value must point to an already locally cloned repo