Skip to content

[WIP] AGENT-1193: Allow openshift-appliance to work with ephemeral payload #1764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
5 changes: 0 additions & 5 deletions agent/04_agent_prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ENTRYNAME>_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
Expand Down
6 changes: 3 additions & 3 deletions agent/05_agent_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 12 additions & 23 deletions oc_mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,21 @@ 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

}

# 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
Expand All @@ -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

}
Expand All @@ -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
}
8 changes: 2 additions & 6 deletions oc_mirror_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down