Skip to content

Commit 73bb609

Browse files
committed
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.
1 parent 39a6bd2 commit 73bb609

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

agent/05_agent_configure.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ function get_mirror_info {
238238
# output ImageDigestSources, while prior to that it was ImageContentSources
239239
sed -n -E '/imageContentSources|imageDigestSources/,/^ *$/p' ${MIRROR_LOG_FILE} | tail -n+2 > ${tmpmirrorinfo}
240240
else
241-
results_dir=$(grep ICSP ${WORKING_DIR}/.oc-mirror.log | grep -o 'oc-mirror[^;]*')
242-
sed -ne '/repository/,/---/p' ${WORKING_DIR}/${results_dir}/imageContentSourcePolicy.yaml > ${tmpmirrorinfo}
243-
sed -i '/repositoryDigestMirrors/d;/---/d' ${tmpmirrorinfo}
241+
# Get the mirror config from the idms file generated by oc-mirror
242+
idms_file=${WORKING_DIR}/working-dir/cluster-resources/idms-oc-mirror.yaml
243+
sed -ne '/imageDigestMirrors:$/,/^status:/{/imageDigestMirrors:$/d;/^status:/d;p;}' $idms_file | sed 's/ //' > ${tmpmirrorinfo}
244244
fi
245245

246246
if [[ ${AGENT_USE_ZTP_MANIFESTS} == true ]]; then

common.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,6 @@ if [[ "${MIRROR_IMAGES,,}" != "false" ]] && [[ "${MIRROR_IMAGES,,}" == "true" ||
520520
if [[ "${MIRROR_COMMAND}" == "oc-mirror" ]]; then
521521
# Use the string that is generated by the output of oc-mirror
522522
export LOCAL_IMAGE_URL_SUFFIX="openshift/release-images"
523-
524-
# set up the channel using the most recent candidate release
525-
pushd ${WORKING_DIR}
526-
release_candidate=`oc-mirror list releases --channel=candidate-${OPENSHIFT_RELEASE_STREAM} | tail -1`
527-
popd
528-
export OPENSHIFT_RELEASE_TAG="${release_candidate}-$(uname -m)"
529523
fi
530524

531525
# We're going to be using a locally modified release image

oc_mirror.sh

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,21 @@ function create_file_imageset() {
7878

7979
imageset=$1
8080

81-
latest_release=$(oc-mirror list releases --channel candidate-${OPENSHIFT_RELEASE_STREAM}| tail -n1)
82-
83-
# Note that the archiveSize defines the maximum size, in GiB, of each file within the image set.
84-
# This must be large enough to include all images in one file for the publish.
8581
cat > "${imageset}" << EOF
86-
apiVersion: mirror.openshift.io/v1alpha2
8782
kind: ImageSetConfiguration
88-
archiveSize: 16
89-
storageConfig:
90-
local:
91-
path: metadata
83+
apiVersion: mirror.openshift.io/v2alpha1
9284
mirror:
9385
platform:
94-
architectures:
95-
- "amd64"
96-
channels:
97-
- name: candidate-${OPENSHIFT_RELEASE_STREAM}
98-
minVersion: $latest_release
99-
maxVersion: $latest_release
100-
type: ocp
86+
graph: true
87+
release: $OPENSHIFT_RELEASE_IMAGE
10188
additionalImages:
10289
- name: registry.redhat.io/ubi8/ubi:latest
10390
EOF
10491

10592
}
10693

10794
# Mirror the upstream channel directly to the local registry
95+
# Note that this method is only valid with oc mirror v1
10896
function mirror_to_mirror_publish() {
10997

11098
# Create imageset containing the local URL and the OCP release to mirror
@@ -124,18 +112,16 @@ function mirror_to_file() {
124112
config=${1}
125113

126114
pushd ${WORKING_DIR}
127-
oc_mirror_dir=$(mktemp --tmpdir -d "oc-mirror-files--XXXXXXXXXX")
128-
_tmpfiles="$_tmpfiles $oc_mirror_dir"
129-
oc-mirror --config ${config} file://${oc_mirror_dir} --ignore-history
130-
archive_file="$(ls ${oc_mirror_dir}/mirror_seq*)"
115+
oc-mirror --v2 --config ${config} file://${WORKING_DIR}
131116
popd
132-
133117
}
134118

135119
function publish_image() {
136120

121+
config=${1}
122+
137123
pushd ${WORKING_DIR}
138-
oc-mirror --from $archive_file docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT} --dest-skip-tls --skip-metadata-check
124+
oc-mirror --v2 --config ${config} --from file://${WORKING_DIR} docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}
139125
popd
140126

141127
}
@@ -156,6 +142,9 @@ function setup_oc_mirror() {
156142

157143
mirror_to_file $tmpimageset
158144

159-
publish_image
145+
publish_image $tmpimageset
146+
147+
# remove interim file
148+
rm ${WORKING_DIR}/mirror_*.tar
160149
fi
161150
}

oc_mirror_cleanup.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ if [[ -f "/usr/local/bin/oc-mirror" ]]; then
1414
sudo rm "/usr/local/bin/oc-mirror"
1515
fi
1616

17-
if [ -f "${WORKING_DIR}/.oc-mirror.log" ]; then
18-
rm "${WORKING_DIR}/.oc-mirror.log"
19-
fi
20-
21-
if [ -d "${WORKING_DIR}/oc-mirror-workspace" ]; then
22-
rm -rf "${WORKING_DIR}/oc-mirror-workspace"
17+
if [ -d "${WORKING_DIR}/working-dir" ]; then
18+
rm -rf "${WORKING_DIR}/working-dir"
2319
fi
2420

2521
if [ -d "${WORKING_DIR}/quay-install" ]; then

0 commit comments

Comments
 (0)