Skip to content

Commit c6dbbd1

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 1bddef6 commit c6dbbd1

File tree

6 files changed

+22
-95
lines changed

6 files changed

+22
-95
lines changed

agent/05_agent_configure.sh

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

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

agent/roles/manifests/templates/install-config_baremetal_yaml.j2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ platform:
5656
baremetal:
5757
apiVIPs:
5858
{% set a_vips = api_vips.split(',') %}
59-
{% for api_vip in a_vips %}
60-
- {{ api_vip }}
61-
{% endfor %}
59+
- {{ a_vips[0] }}
6260
ingressVIPs:
6361
{% set i_vips = ingress_vips.split(',') %}
6462
{% for ingress_vip in i_vips %}
@@ -133,4 +131,4 @@ proxy:
133131
{% if no_proxy %}
134132
noProxy: "{{ no_proxy }}"
135133
{% endif %}
136-
{% endif %}
134+
{% endif %}

common.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,6 @@ if [[ "${MIRROR_IMAGES,,}" != "false" ]] && [[ "${MIRROR_IMAGES,,}" == "true" ||
551551
if [[ "${MIRROR_COMMAND}" == "oc-mirror" ]]; then
552552
# Use the string that is generated by the output of oc-mirror
553553
export LOCAL_IMAGE_URL_SUFFIX="openshift/release-images"
554-
555-
# set up the channel using the most recent candidate release
556-
pushd ${WORKING_DIR}
557-
release_candidate=`oc-mirror list releases --channel=candidate-${OPENSHIFT_RELEASE_STREAM} | tail -1`
558-
popd
559-
export OPENSHIFT_RELEASE_TAG="${release_candidate}-$(uname -m)"
560554
fi
561555

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

config_example.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,6 @@ set -x
645645
# Default: oc-adm
646646
#export MIRROR_COMMAND=oc-adm
647647

648-
# OC_MIRROR_TO_FILE -
649-
# When MIRROR_IMAGES is true and MIRROR_COMMAND is oc-mirror, if this is set it
650-
# will cause the mirror to be generated in a 2-step process. First the contents of
651-
# the mirror is stored in a tarfile and then the tarfile is published to the registry
652-
# Default is unset
653-
654648
# When the MIRROR_COMMAND is set to 'oc-mirror' the auths for the mirror will be added
655649
# to DOCKER_CONFIG_FILE or an UNAUTHORIZED error will result.
656650
# An example entry in this file is:

oc_mirror.sh

Lines changed: 15 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -49,93 +49,39 @@ function setup_quay_mirror_registry() {
4949
popd
5050
}
5151

52-
function create_registry_imageset() {
53-
54-
imageset=$1
55-
56-
cat > "${imageset}" << EOF
57-
apiVersion: mirror.openshift.io/v1alpha2
58-
kind: ImageSetConfiguration
59-
archiveSize: 4
60-
storageConfig:
61-
registry:
62-
imageURL: ${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/origin:latest
63-
skipTLS: true
64-
mirror:
65-
platform:
66-
architectures:
67-
- "amd64"
68-
channels:
69-
- name: candidate-${OPENSHIFT_RELEASE_STREAM}
70-
type: ocp
71-
additionalImages:
72-
- name: registry.redhat.io/ubi8/ubi:latest
73-
EOF
74-
75-
}
76-
7752
function create_file_imageset() {
7853

7954
imageset=$1
8055

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.
8556
cat > "${imageset}" << EOF
86-
apiVersion: mirror.openshift.io/v1alpha2
8757
kind: ImageSetConfiguration
88-
archiveSize: 16
89-
storageConfig:
90-
local:
91-
path: metadata
58+
apiVersion: mirror.openshift.io/v2alpha1
9259
mirror:
9360
platform:
94-
architectures:
95-
- "amd64"
96-
channels:
97-
- name: candidate-${OPENSHIFT_RELEASE_STREAM}
98-
minVersion: $latest_release
99-
maxVersion: $latest_release
100-
type: ocp
61+
graph: true
62+
release: $OPENSHIFT_RELEASE_IMAGE
10163
additionalImages:
10264
- name: registry.redhat.io/ubi8/ubi:latest
10365
EOF
10466

10567
}
10668

107-
# Mirror the upstream channel directly to the local registry
108-
function mirror_to_mirror_publish() {
109-
110-
# Create imageset containing the local URL and the OCP release to mirror
111-
tmpimageset=$(mktemp --tmpdir "imageset--XXXXXXXXXX")
112-
_tmpfiles="$_tmpfiles $tmpimageset"
113-
114-
create_registry_imageset $tmpimageset
115-
116-
pushd ${WORKING_DIR}
117-
oc mirror --dest-skip-tls --config ${tmpimageset} docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}
118-
popd
119-
}
120-
12169
# Use the oc-mirror command to generate a tar file of the release image
12270
function mirror_to_file() {
12371

12472
config=${1}
12573

12674
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*)"
75+
oc-mirror --v2 --config ${config} file://${WORKING_DIR}
13176
popd
132-
13377
}
13478

13579
function publish_image() {
13680

81+
config=${1}
82+
13783
pushd ${WORKING_DIR}
138-
oc-mirror --from $archive_file docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT} --dest-skip-tls --skip-metadata-check
84+
oc-mirror --v2 --config ${config} --from file://${WORKING_DIR} docker://${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}
13985
popd
14086

14187
}
@@ -146,16 +92,15 @@ function setup_oc_mirror() {
14692

14793
update_docker_config
14894

149-
if [ -z "${OC_MIRROR_TO_FILE}" ]; then
150-
mirror_to_mirror_publish
151-
else
152-
tmpimageset=$(mktemp --tmpdir "imageset--XXXXXXXXXX")
153-
_tmpfiles="$_tmpfiles $tmpimageset"
95+
tmpimageset=$(mktemp --tmpdir "imageset--XXXXXXXXXX")
96+
_tmpfiles="$_tmpfiles $tmpimageset"
15497

155-
create_file_imageset $tmpimageset
98+
create_file_imageset $tmpimageset
15699

157-
mirror_to_file $tmpimageset
100+
mirror_to_file $tmpimageset
158101

159-
publish_image
160-
fi
102+
publish_image $tmpimageset
103+
104+
# remove interim file
105+
rm ${WORKING_DIR}/mirror_*.tar
161106
}

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)