Skip to content

Commit cb85d33

Browse files
committed
Use alternative approach to extract from installer container
1 parent 60a55b8 commit cb85d33

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

03_build_installer.sh

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mkdir -p $OCP_DIR
1515
if [ -z "$KNI_INSTALL_FROM_GIT" ]; then
1616
# Extract openshift-install from the release image
1717
extract_installer "${OPENSHIFT_RELEASE_IMAGE}" $OCP_DIR
18+
extract_rhcos_json "${OPENSHIFT_RELEASE_IMAGE}" $OCP_DIR
1819
else
1920
# Clone and build the installer from source
2021
clone_installer

ocp_install_env.sh

+18
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ function extract_installer() {
3939
extract_command openshift-baremetal-install "$1" "$2"
4040
}
4141

42+
function extract_rhcos_json() {
43+
local release_image
44+
local outdir
45+
46+
release_image="$1"
47+
outdir="$2"
48+
pullsecret_file=$(mktemp "pullsecret--XXXXXXXXXX")
49+
50+
echo "${PULL_SECRET}" > "${pullsecret_file}"
51+
52+
baremetal_image=$(oc adm release info --image-for=baremetal-installer --registry-config "$pullsecret_file" "$release_image")
53+
baremetal_container=$(podman create "$baremetal_image")
54+
55+
# This is OK to fail as rhcos.json isn't available in every release,
56+
# we'll download it from github if it's not available
57+
podman cp "$baremetal_container":/var/cache/rhcos.json "$outdir" || true
58+
}
59+
4260
function clone_installer() {
4361
# Clone repo, if not already present
4462
if [[ ! -d $OPENSHIFT_INSTALL_PATH ]]; then

rhcos.sh

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
# If we're in OpenShift CI, get the sha for our PR. The one openshift-install version
2-
# reports isn't correct due to how CI rebases the PR before building.
3-
#
4-
# FIXME(stbenjam): If a PR branch is not current with master, there is a
5-
# potential for rhcos.json to be out of date. The potential solutions to
6-
# this are not ideal, we'll either have to checkout the repo ourselves and
7-
# check or make a bunch of API calls to see if the PR modified
8-
# rhcos.json, otherwise just always get master.
9-
if [[ "$JOB_NAME" =~ "openshift-installer" ]]; then
10-
OPENSHIFT_INSTALL_COMMIT=${PULL_PULL_SHA:-$(echo "$JOB_SPEC" | jq -r '.refs.pulls[0].sha')}
1+
if [[ -f "$OCP_DIR/rhcos.json" ]]; then
2+
MACHINE_OS_IMAGE_JSON=$(cat "$OCP_DIR/rhcos.json")
113
else
124
# Get the git commit that the openshift installer was built from
135
OPENSHIFT_INSTALL_COMMIT=$($OPENSHIFT_INSTALLER version | grep commit | cut -d' ' -f4)
14-
fi
156

16-
# Get the rhcos.json for that commit
17-
OPENSHIFT_INSTALLER_MACHINE_OS=${OPENSHIFT_INSTALLER_MACHINE_OS:-https://raw.githubusercontent.com/openshift/installer/$OPENSHIFT_INSTALL_COMMIT/data/data/rhcos.json}
7+
# Get the rhcos.json for that commit
8+
OPENSHIFT_INSTALLER_MACHINE_OS=${OPENSHIFT_INSTALLER_MACHINE_OS:-https://raw.githubusercontent.com/openshift/installer/$OPENSHIFT_INSTALL_COMMIT/data/data/rhcos.json}
189

19-
# Get the rhcos.json for that commit, and find the baseURI and openstack image path
20-
MACHINE_OS_IMAGE_JSON=$(curl "${OPENSHIFT_INSTALLER_MACHINE_OS}")
10+
# Get the rhcos.json for that commit, and find the baseURI and openstack image path
11+
MACHINE_OS_IMAGE_JSON=$(curl "${OPENSHIFT_INSTALLER_MACHINE_OS}")
12+
fi
2113

2214
export MACHINE_OS_INSTALLER_IMAGE_URL=$(echo "${MACHINE_OS_IMAGE_JSON}" | jq -r '.baseURI + .images.openstack.path')
2315
export MACHINE_OS_INSTALLER_IMAGE_SHA256=$(echo "${MACHINE_OS_IMAGE_JSON}" | jq -r '.images.openstack.sha256')

0 commit comments

Comments
 (0)