Skip to content

Commit f9f3ce4

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 4589dfb commit f9f3ce4

File tree

8 files changed

+63
-36
lines changed

8 files changed

+63
-36
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: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ 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+
27+
if [ -z "$KNI_INSTALL_FROM_GIT" ]; then
28+
export OPENSHIFT_INSTALLER=${OPENSHIFT_INSTALLER:-ocp/openshift-baremetal-install}
29+
else
30+
export OPENSHIFT_INSTALLER=${OPENSHIFT_INSTALLER:-$GOPATH/src/github.com/openshift/installer/bin/openshift-install}
31+
32+
# The installer defaults to origin/CI releases, e.g registry.svc.ci.openshift.org/origin/release:4.2
33+
# Which currently don't work for us ref
34+
# https://github.com/openshift/ironic-inspector-image/pull/17
35+
# Until we can align OPENSHIFT_RELEASE_IMAGE with the installer default, we still need
36+
# to set OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE for openshift-install source builds
37+
export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE="${OPENSHIFT_RELEASE_IMAGE}"
38+
fi
39+
2240
# Set variables
2341
# Additional DNS
2442
ADDN_DNS=${ADDN_DNS:-}
@@ -47,10 +65,6 @@ export NUM_MASTERS=${NUM_MASTERS:-"3"}
4765
export NUM_WORKERS=${NUM_WORKERS:-"1"}
4866
export VM_EXTRADISKS=${VM_EXTRADISKS:-"false"}
4967

50-
export RHCOS_INSTALLER_IMAGE_URL="https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.2/42.80.20190725.1/rhcos-42.80.20190725.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-
5468
# Ironic vars
5569
export IRONIC_IMAGE=${IRONIC_IMAGE:-"quay.io/metal3-io/ironic:master"}
5670
export IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"quay.io/metal3-io/ironic-inspector:master"}

ocp_install_env.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ export SSH_PUB_KEY="${SSH_PUB_KEY:-$(cat $HOME/.ssh/id_rsa.pub)}"
99
export EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-"192.168.111.0/24"}
1010
export DNS_VIP=${DNS_VIP:-"192.168.111.2"}
1111

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-
1712
function extract_command() {
1813
local release_image
1914
local cmd
@@ -51,7 +46,6 @@ function extract_installer() {
5146
outdir="$2"
5247

5348
extract_command openshift-baremetal-install "$1" "$2"
54-
export OPENSHIFT_INSTALLER="${outdir}/openshift-baremetal-install"
5549
}
5650

5751
function clone_installer() {
@@ -67,15 +61,6 @@ function build_installer() {
6761
cd $OPENSHIFT_INSTALL_PATH
6862
TAGS="libvirt baremetal" hack/build.sh
6963
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}"
7964
}
8065

8166
function generate_ocp_install_config() {
@@ -93,6 +78,7 @@ function generate_ocp_install_config() {
9378
# TODO - Change worker replicas to ${NUM_WORKERS} once the machine-api-operator
9479
# deploys the baremetal-operator
9580

81+
mkdir -p "${outdir}"
9682
cat > "${outdir}/install-config.yaml" << EOF
9783
apiVersion: v1
9884
baseDomain: ${BASE_DOMAIN}

rhcos.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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, and find the baseURI and openstack image path
5+
RHCOS_IMAGE_JSON=$(curl https://raw.githubusercontent.com/openshift/installer/$OPENSHIFT_INSTALL_COMMIT/data/data/rhcos.json)
6+
RHCOS_IMAGE_BASE_URI=$(echo $RHCOS_IMAGE_JSON | jq -r '.baseURI')
7+
RHCOS_IMAGE_FILENAME=$(echo $RHCOS_IMAGE_JSON | jq -r '.images.openstack.path')
8+
9+
export RHCOS_INSTALLER_IMAGE_URL="$RHCOS_IMAGE_BASE_URI$RHCOS_IMAGE_FILENAME"
10+
export RHCOS_IMAGE_URL=${RHCOS_IMAGE_URL:-${RHCOS_INSTALLER_IMAGE_URL}}
11+
export RHCOS_IMAGE_FILENAME_LATEST="rhcos-ootpa-latest.qcow2"

run_ci.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
set -ex
33

4+
# Temporarily run from git
5+
export KNI_INSTALL_FROM_GIT=true
6+
47
# grabs files and puts them into $LOGDIR to be saved as jenkins artifacts
58
function getlogs(){
69
LOGDIR=/home/notstack/dev-scripts/logs

0 commit comments

Comments
 (0)