Skip to content
Merged
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
1 change: 1 addition & 0 deletions 03_build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mkdir -p $OCP_DIR
if [ -z "$KNI_INSTALL_FROM_GIT" ]; then
# Extract openshift-install from the release image
extract_installer "${OPENSHIFT_RELEASE_IMAGE}" $OCP_DIR
extract_rhcos_json "${OPENSHIFT_RELEASE_IMAGE}" $OCP_DIR
else
# Clone and build the installer from source
clone_installer
Expand Down
22 changes: 22 additions & 0 deletions ocp_install_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ function extract_installer() {
extract_command openshift-baremetal-install "$1" "$2"
}

function extract_rhcos_json() {
local release_image
local outdir

release_image="$1"
outdir="$2"
pullsecret_file=$(mktemp "pullsecret--XXXXXXXXXX")

echo "${PULL_SECRET}" > "${pullsecret_file}"

baremetal_image=$(oc adm release info --image-for=baremetal-installer --registry-config "$pullsecret_file" "$release_image")
baremetal_container=$(podman create --authfile "$pullsecret_file" "$baremetal_image")

# This is OK to fail as rhcos.json isn't available in every release,
# we'll download it from github if it's not available
podman cp "$baremetal_container":/var/cache/rhcos.json "$outdir" || true

podman rm -f "$baremetal_container"
rm -rf "${pullsecret_file}"
}

function clone_installer() {
# Clone repo, if not already present
if [[ ! -d $OPENSHIFT_INSTALL_PATH ]]; then
Expand All @@ -52,6 +73,7 @@ function build_installer() {
cd $OPENSHIFT_INSTALL_PATH
TAGS="libvirt baremetal" hack/build.sh
popd
cp "$OPENSHIFT_INSTALL_PATH/data/data/rhcos.json" "$OCP_DIR"
}

# FIXME(stbenjam): This is not available in 4.3 (yet)
Expand Down
25 changes: 19 additions & 6 deletions rhcos.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# Get the git commit that the openshift installer was built from
OPENSHIFT_INSTALL_COMMIT=$($OPENSHIFT_INSTALLER version | grep commit | cut -d' ' -f4)
if [[ -f "$OCP_DIR/rhcos.json" ]]; then
MACHINE_OS_IMAGE_JSON=$(cat "$OCP_DIR/rhcos.json")
else

# Get the rhcos.json for that commit
OPENSHIFT_INSTALLER_MACHINE_OS=${OPENSHIFT_INSTALLER_MACHINE_OS:-https://raw.githubusercontent.com/openshift/installer/$OPENSHIFT_INSTALL_COMMIT/data/data/rhcos.json}
if [[ -v JOB_NAME ]] && [[ "$JOB_NAME" =~ "openshift-installer" ]]; then
# Get the SHA from the PR if we're in CI
OPENSHIFT_INSTALL_COMMIT=${PULL_PULL_SHA:-$(echo "$JOB_SPEC" | jq -r '.refs.pulls[0].sha')}
else
# Get the git commit that the openshift installer was built from
OPENSHIFT_INSTALL_COMMIT=$($OPENSHIFT_INSTALLER version | grep commit | cut -d' ' -f4)
fi

# Get the rhcos.json for that commit, and find the baseURI and openstack image path
MACHINE_OS_IMAGE_JSON=$(curl "${OPENSHIFT_INSTALLER_MACHINE_OS}")
# Get the git commit that the openshift installer was built from
OPENSHIFT_INSTALL_COMMIT=$($OPENSHIFT_INSTALLER version | grep commit | cut -d' ' -f4)

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

# Get the rhcos.json for that commit, and find the baseURI and openstack image path
MACHINE_OS_IMAGE_JSON=$(curl "${OPENSHIFT_INSTALLER_MACHINE_OS}")
fi

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