Skip to content

Commit ceb9867

Browse files
committed
Always use RHCOS version from installer
Instead of hardcoding the RHCOS version in dev-scripts, by re-ordering some things like extracting/building the installer first, we can use the rhcos.json from the installer to find out which RHCOS version we should be using.
1 parent 88a71ad commit ceb9867

File tree

8 files changed

+66
-41
lines changed

8 files changed

+66
-41
lines changed

03_build_installer.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
set -e
4+
5+
source logging.sh
6+
source utils.sh
7+
source common.sh
8+
source ocp_install_env.sh
9+
10+
# Extract an updated client tools from the release image
11+
extract_oc "${OPENSHIFT_RELEASE_IMAGE}"
12+
13+
mkdir -p ocp/
14+
15+
if [ -z "$KNI_INSTALL_FROM_GIT" ]; then
16+
# Extract openshift-install from the release image
17+
extract_installer "${OPENSHIFT_RELEASE_IMAGE}" ocp/
18+
else
19+
# Clone and build the installer from source
20+
clone_installer
21+
build_installer
22+
fi

04_setup_ironic.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -ex
44

55
source logging.sh
66
source common.sh
7+
source rhcos.sh
78

89
# Either pull or build the ironic images
910
# To build the IRONIC image set

06_create_cluster.sh

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ source logging.sh
66
source utils.sh
77
source common.sh
88
source ocp_install_env.sh
9+
source rhcos.sh
910

1011
# Do some PULL_SECRET sanity checking
1112
if [[ "${OPENSHIFT_RELEASE_IMAGE}" == *"registry.svc.ci.openshift.org"* ]]; then
@@ -32,21 +33,7 @@ else
3233
INGRESS_VIP=$(dig +noall +answer "test.apps.${CLUSTER_DOMAIN}" | awk '{print $NF}')
3334
fi
3435

35-
if [ ! -d ocp ]; then
36-
mkdir -p ocp
37-
38-
# Extract an updated client tools from the release image
39-
extract_oc ${OPENSHIFT_RELEASE_IMAGE}
40-
41-
if [ -z "$KNI_INSTALL_FROM_GIT" ]; then
42-
# Extract openshift-install from the release image
43-
extract_installer "${OPENSHIFT_RELEASE_IMAGE}" ocp/
44-
else
45-
# Clone and build the installer from source
46-
clone_installer
47-
build_installer
48-
fi
49-
36+
if [ ! -f ocp/install-config.yaml ]; then
5037
# Validate there are enough nodes to avoid confusing errors later..
5138
NODES_LEN=$(jq '.nodes | length' ${NODES_FILE})
5239
if (( $NODES_LEN < ( $NUM_MASTERS + $NUM_WORKERS ) )); then

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
.PHONY: default all requirements configure ironic ocp_run register_hosts clean ocp_cleanup ironic_cleanup host_cleanup bell csr_hack
2-
default: requirements configure ironic ocp_run register_hosts csr_hack bell
2+
default: requirements configure build_installer ironic ocp_run register_hosts csr_hack bell
33

44
all: default
55

6-
redeploy: ocp_cleanup ironic_cleanup ironic ocp_run register_hosts csr_hack bell
6+
redeploy: ocp_cleanup ironic_cleanup build_installer ironic ocp_run register_hosts csr_hack bell
77

88
requirements:
99
./01_install_requirements.sh
1010

1111
configure:
1212
./02_configure_host.sh
1313

14+
build_installer:
15+
./03_build_installer.sh
16+
1417
ironic:
1518
./04_setup_ironic.sh
1619

common.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ if [ -z "${CONFIG:-}" ]; then
1919
fi
2020
source $CONFIG
2121

22+
#
23+
# See https://origin-release.svc.ci.openshift.org/ for release details
24+
#
25+
export OPENSHIFT_RELEASE_IMAGE="${OPENSHIFT_RELEASE_IMAGE:-registry.svc.ci.openshift.org/ocp/release:4.2}"
26+
export OPENSHIFT_INSTALL_PATH="$GOPATH/src/github.com/openshift/installer"
27+
28+
if [ -z "$KNI_INSTALL_FROM_GIT" ]; then
29+
export OPENSHIFT_INSTALLER=${OPENSHIFT_INSTALLER:-ocp/openshift-baremetal-install}
30+
else
31+
export OPENSHIFT_INSTALLER=${OPENSHIFT_INSTALLER:-$OPENSHIFT_INSTALL_PATH/bin/openshift-install}
32+
33+
# This is an URI so we can use curl for either the file on GitHub, or locally
34+
export OPENSHIFT_INSTALLER_RHCOS=${OPENSHIFT_INSTALLER_RHCOS:-file:///$OPENSHIFT_INSTALL_PATH/data/data/rhcos.json}
35+
36+
# The installer defaults to origin/CI releases, e.g registry.svc.ci.openshift.org/origin/release:4.2
37+
# Which currently don't work for us ref
38+
# https://github.com/openshift/ironic-inspector-image/pull/17
39+
# Until we can align OPENSHIFT_RELEASE_IMAGE with the installer default, we still need
40+
# to set OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE for openshift-install source builds
41+
export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE="${OPENSHIFT_RELEASE_IMAGE}"
42+
fi
43+
2244
# Set variables
2345
# Additional DNS
2446
ADDN_DNS=${ADDN_DNS:-}
@@ -47,10 +69,6 @@ export NUM_MASTERS=${NUM_MASTERS:-"3"}
4769
export NUM_WORKERS=${NUM_WORKERS:-"1"}
4870
export VM_EXTRADISKS=${VM_EXTRADISKS:-"false"}
4971

50-
export RHCOS_INSTALLER_IMAGE_URL="https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.2/42.80.20190827.1/rhcos-42.80.20190827.1-openstack.qcow2"
51-
export RHCOS_IMAGE_URL=${RHCOS_IMAGE_URL:-${RHCOS_INSTALLER_IMAGE_URL}}
52-
export RHCOS_IMAGE_FILENAME_LATEST="rhcos-ootpa-latest.qcow2"
53-
5472
# Ironic vars
5573
export IRONIC_IMAGE=${IRONIC_IMAGE:-"quay.io/metal3-io/ironic:master"}
5674
export IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"quay.io/metal3-io/ironic-inspector:master"}

ocp_install_env.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
eval "$(go env)"
22

3-
export OPENSHIFT_INSTALL_PATH="$GOPATH/src/github.com/openshift/installer"
4-
export OPENSHIFT_INSTALL_DATA="$OPENSHIFT_INSTALL_PATH/data/data"
53
export BASE_DOMAIN=${BASE_DOMAIN:-test.metalkube.org}
64
export CLUSTER_NAME=${CLUSTER_NAME:-ostest}
75
export CLUSTER_DOMAIN="${CLUSTER_NAME}.${BASE_DOMAIN}"
86
export SSH_PUB_KEY="${SSH_PUB_KEY:-$(cat $HOME/.ssh/id_rsa.pub)}"
97
export EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-"192.168.111.0/24"}
108
export DNS_VIP=${DNS_VIP:-"192.168.111.2"}
119

12-
#
13-
# See https://origin-release.svc.ci.openshift.org/ for release details
14-
#
15-
export OPENSHIFT_RELEASE_IMAGE="${OPENSHIFT_RELEASE_IMAGE:-registry.svc.ci.openshift.org/ocp/release:4.2}"
16-
1710
function extract_command() {
1811
local release_image
1912
local cmd
@@ -51,7 +44,6 @@ function extract_installer() {
5144
outdir="$2"
5245

5346
extract_command openshift-baremetal-install "$1" "$2"
54-
export OPENSHIFT_INSTALLER="${outdir}/openshift-baremetal-install"
5547
}
5648

5749
function clone_installer() {
@@ -67,15 +59,6 @@ function build_installer() {
6759
cd $OPENSHIFT_INSTALL_PATH
6860
TAGS="libvirt baremetal" hack/build.sh
6961
popd
70-
71-
export OPENSHIFT_INSTALLER="$OPENSHIFT_INSTALL_PATH/bin/openshift-install"
72-
73-
# The installer defaults to origin/CI releases, e.g registry.svc.ci.openshift.org/origin/release:4.2
74-
# Which currently don't work for us ref
75-
# https://github.com/openshift/ironic-inspector-image/pull/17
76-
# Until we can align OPENSHIFT_RELEASE_IMAGE with the installer default, we still need
77-
# to set OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE for openshift-install source builds
78-
export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE="${OPENSHIFT_RELEASE_IMAGE}"
7962
}
8063

8164
function generate_ocp_install_config() {
@@ -93,6 +76,7 @@ function generate_ocp_install_config() {
9376
# TODO - Change worker replicas to ${NUM_WORKERS} once the machine-api-operator
9477
# deploys the baremetal-operator
9578

79+
mkdir -p "${outdir}"
9680
cat > "${outdir}/install-config.yaml" << EOF
9781
apiVersion: v1
9882
baseDomain: ${BASE_DOMAIN}

rhcos.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Get the git commit that the openshift installer was built from
2+
OPENSHIFT_INSTALL_COMMIT=$($OPENSHIFT_INSTALLER version | grep commit | cut -d' ' -f4)
3+
4+
# Get the rhcos.json for that commit
5+
OPENSHIFT_INSTALLER_RHCOS=${OPENSHIFT_INSTALLER_RHCOS:-https://raw.githubusercontent.com/openshift/installer/$OPENSHIFT_INSTALL_COMMIT/data/data/rhcos.json}
6+
7+
# Get the rhcos.json for that commit, and find the baseURI and openstack image path
8+
RHCOS_IMAGE_JSON=$(curl "${OPENSHIFT_INSTALLER_RHCOS}")
9+
export RHCOS_INSTALLER_IMAGE_URL=$(echo "${RHCOS_IMAGE_JSON}" | jq -r '.baseURI + .images.openstack.path')
10+
export RHCOS_INSTALLER_IMAGE_URL="$RHCOS_IMAGE_BASE_URI$RHCOS_IMAGE_FILENAME"
11+
export RHCOS_IMAGE_URL=${RHCOS_IMAGE_URL:-${RHCOS_INSTALLER_IMAGE_URL}}
12+
export RHCOS_IMAGE_FILENAME_LATEST="rhcos-ootpa-latest.qcow2"

run_ci.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ done
142142

143143
# Run dev-scripts
144144
set -o pipefail
145-
# TODO - Run all steps again once the baremetal-operator pod is fixed
146-
#timeout -s 9 85m make |& ts "%b %d %H:%M:%S | " |& sed -e 's/.*auths.*/*** PULL_SECRET ***/g'
147-
timeout -s 9 85m make requirements configure ironic ocp_run register_hosts |& ts "%b %d %H:%M:%S | " |& sed -e 's/.*auths.*/*** PULL_SECRET ***/g'
145+
timeout -s 9 85m make |& ts "%b %d %H:%M:%S | " |& sed -e 's/.*auths.*/*** PULL_SECRET ***/g'
148146

149147
# Deployment is complete, but now wait to ensure the worker node comes up.
150148
export KUBECONFIG=ocp/auth/kubeconfig

0 commit comments

Comments
 (0)