From 65a987c74fb6363892c6fb1114009fdbccdba5dd Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Mon, 26 Aug 2019 08:20:52 -0400 Subject: [PATCH] Extract installer using `oc adm release extract` This changes dev-scripts to use oc adm release extract, which produces an openshift-baremetal-install binary with the release payload set from which it was extracted. This means we no longer need to set OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE. --- 01_install_requirements.sh | 2 +- 06_create_cluster.sh | 7 +++++-- ocp_install_env.sh | 40 ++++++++++++++++++++++++++------------ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/01_install_requirements.sh b/01_install_requirements.sh index f6ff954d5..369fb2b5f 100755 --- a/01_install_requirements.sh +++ b/01_install_requirements.sh @@ -165,7 +165,7 @@ oc_date=0 if which oc 2>&1 >/dev/null ; then oc_date=$(date -d $(oc version -o json | jq -r '.clientVersion.buildDate') +%s) fi -if [ ! -f ${oc_tools_dir}/${oc_tools_local_file} ] || [ $oc_date -lt 1559308936 ]; then +if [ ! -f ${oc_tools_dir}/${oc_tools_local_file} ] || [ $oc_date -lt 1566755586 ]; then mkdir -p ${oc_tools_dir} cd ${oc_tools_dir} wget https://mirror.openshift.com/pub/openshift-v4/clients/oc/${oc_version}/linux/oc.tar.gz -O ${oc_tools_local_file} diff --git a/06_create_cluster.sh b/06_create_cluster.sh index 834d81c66..42bad5e10 100755 --- a/06_create_cluster.sh +++ b/06_create_cluster.sh @@ -8,7 +8,7 @@ source common.sh source ocp_install_env.sh # Do some PULL_SECRET sanity checking -if [[ "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" == *"registry.svc.ci.openshift.org"* ]]; then +if [[ "${OPENSHIFT_RELEASE_IMAGE}" == *"registry.svc.ci.openshift.org"* ]]; then if [[ "${PULL_SECRET}" != *"registry.svc.ci.openshift.org"* ]]; then echo "Please get a valid pull secret for registry.svc.ci.openshift.org." exit 1 @@ -35,9 +35,12 @@ fi if [ ! -d ocp ]; then mkdir -p ocp + # Extract an updated client tools from the release image + extract_oc ${OPENSHIFT_RELEASE_IMAGE} + if [ -z "$KNI_INSTALL_FROM_GIT" ]; then # Extract openshift-install from the release image - extract_installer "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" ocp/ + extract_installer "${OPENSHIFT_RELEASE_IMAGE}" ocp/ else # Clone and build the installer from source clone_installer diff --git a/ocp_install_env.sh b/ocp_install_env.sh index 6db49ebe5..b019c2fc1 100644 --- a/ocp_install_env.sh +++ b/ocp_install_env.sh @@ -12,32 +12,48 @@ export DNS_VIP=${DNS_VIP:-"192.168.111.2"} # # See https://origin-release.svc.ci.openshift.org/ for release details # -export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE="${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE:-registry.svc.ci.openshift.org/ocp/release:4.2}" +export OPENSHIFT_RELEASE_IMAGE="${OPENSHIFT_RELEASE_IMAGE:-registry.svc.ci.openshift.org/ocp/release:4.2}" -function extract_installer() { +function extract_command() { local release_image + local cmd local outdir + local extract_dir - release_image="$1" - outdir="$2" + cmd="$1" + release_image="$2" + outdir="$3" extract_dir=$(mktemp -d "installer--XXXXXXXXXX") pullsecret_file=$(mktemp "pullsecret--XXXXXXXXXX") echo "${PULL_SECRET}" > "${pullsecret_file}" - # FIXME: Find the pullspec for baremetal-installer image and extract the image, until - # https://github.com/openshift/oc/pull/57 is merged - baremetal_image=$(oc adm release info --registry-config "${pullsecret_file}" $OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE -o json | jq -r '.references.spec.tags[] | select(.name == "baremetal-installer") | .from.name') - oc image extract --registry-config "${pullsecret_file}" $baremetal_image --path usr/bin/openshift-install:${extract_dir} - - chmod 755 "${extract_dir}/openshift-install" - mv "${extract_dir}/openshift-install" "${outdir}" - export OPENSHIFT_INSTALLER="${outdir}/openshift-install" + oc adm release extract --registry-config "${pullsecret_file}" --command=$cmd --to "${extract_dir}" ${release_image} + mv "${extract_dir}/${cmd}" "${outdir}" rm -rf "${extract_dir}" rm -rf "${pullsecret_file}" } +# Let's always grab the `oc` from the release we're using. +function extract_oc() { + extract_dir=$(mktemp -d "installer--XXXXXXXXXX") + extract_command oc "$1" "${extract_dir}" + sudo mv "${extract_dir}/oc" /usr/local/bin + rm -rf "${extract_dir}" +} + +function extract_installer() { + local release_image + local outdir + + release_image="$1" + outdir="$2" + + extract_command openshift-baremetal-install "$1" "$2" + export OPENSHIFT_INSTALLER="${outdir}/openshift-baremetal-install" +} + function clone_installer() { # Clone repo, if not already present if [[ ! -d $OPENSHIFT_INSTALL_PATH ]]; then