From fbddf63a1039e562cfb14b35de7dfa079346fb2b Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Thu, 23 May 2019 11:56:23 -0400 Subject: [PATCH] Move image downloads into resource downloader containers Move the download of the IPA and CoreOS image download into containers. These containers can be used to download the images for ironic running on the bootstrap and master nodes. When downloading images on the master nodes the container can be instructed to get the image from the bootstrap http server by setting CACHEURL=http://172.22.0.1/images --- 01_install_requirements.sh | 1 - 04_setup_ironic.sh | 30 ++++++++---------------------- common.sh | 10 ++-------- get_images.sh | 23 ----------------------- 4 files changed, 10 insertions(+), 54 deletions(-) delete mode 100755 get_images.sh diff --git a/01_install_requirements.sh b/01_install_requirements.sh index bcb78536f..4ac527930 100755 --- a/01_install_requirements.sh +++ b/01_install_requirements.sh @@ -63,7 +63,6 @@ sudo yum -y install \ ansible \ bind-utils \ jq \ - libguestfs-tools \ libvirt \ libvirt-devel \ libvirt-daemon-kvm \ diff --git a/04_setup_ironic.sh b/04_setup_ironic.sh index ff8d0ef6d..b1cf9b72a 100755 --- a/04_setup_ironic.sh +++ b/04_setup_ironic.sh @@ -5,13 +5,10 @@ set -ex source logging.sh source common.sh -# Get the various images -source get_images.sh - # Either pull or build the ironic images # To build the IRONIC image set # IRONIC_IMAGE=https://github.com/metalkube/metalkube-ironic -for IMAGE_VAR in IRONIC_IMAGE IRONIC_INSPECTOR_IMAGE ; do +for IMAGE_VAR in IRONIC_IMAGE IRONIC_INSPECTOR_IMAGE IPA_DOWNLOADER_IMAGE COREOS_DOWNLOADER_IMAGE ; do IMAGE=${!IMAGE_VAR} # Is it a git repo? if [[ "$IMAGE" =~ "://" ]] ; then @@ -27,24 +24,7 @@ for IMAGE_VAR in IRONIC_IMAGE IRONIC_INSPECTOR_IMAGE ; do fi done -pushd $IRONIC_DATA_DIR/html/images - -# Compress the qcow2 image so that it can be downloaded into -# a smaller /tmp by IPA -if [ ! -e "$RHCOS_IMAGE_FILENAME_COMPRESSED" ] ; then - qemu-img convert -O qcow2 -c "$RHCOS_IMAGE_FILENAME_OPENSTACK" "$RHCOS_IMAGE_FILENAME_COMPRESSED" -fi - -if [ ! -e "${RHCOS_IMAGE_FILENAME_COMPRESSED}.md5sum" -o \ - "$RHCOS_IMAGE_FILENAME_COMPRESSED" -nt "$RHCOS_IMAGE_FILENAME_COMPRESSED.md5sum" ] ; then - md5sum "$RHCOS_IMAGE_FILENAME_COMPRESSED" | cut -f 1 -d " " > "$RHCOS_IMAGE_FILENAME_COMPRESSED.md5sum" -fi - -ln -sf "$RHCOS_IMAGE_FILENAME_COMPRESSED" "$RHCOS_IMAGE_FILENAME_LATEST" -ln -sf "$RHCOS_IMAGE_FILENAME_COMPRESSED.md5sum" "$RHCOS_IMAGE_FILENAME_LATEST.md5sum" -popd - -for name in ironic ironic-inspector dnsmasq httpd mariadb; do +for name in ironic ironic-inspector dnsmasq httpd mariadb ipa-downloader coreos-downloader; do sudo podman ps | grep -w "$name$" && sudo podman kill $name sudo podman ps --all | grep -w "$name$" && sudo podman rm $name -f done @@ -75,6 +55,12 @@ sudo podman run -d --net host --privileged --name ironic --pod ironic-pod \ --env MARIADB_PASSWORD=$mariadb_password \ -v $IRONIC_DATA_DIR:/shared ${IRONIC_IMAGE} +sudo podman run -d --net host --privileged --name ipa-downloader --pod ironic-pod \ + -v $IRONIC_DATA_DIR:/shared ${IPA_DOWNLOADER_IMAGE} /usr/local/bin/get-resource.sh + +sudo podman run -d --net host --privileged --name coreos-downloader --pod ironic-pod \ + -v $IRONIC_DATA_DIR:/shared ${COREOS_DOWNLOADER_IMAGE} /usr/local/bin/get-resource.sh $RHCOS_IMAGE_URL + # Start Ironic Inspector sudo podman run -d --net host --privileged --name ironic-inspector \ --pod ironic-pod -v $IRONIC_DATA_DIR:/shared "${IRONIC_INSPECTOR_IMAGE}" diff --git a/common.sh b/common.sh index b59940374..2e2106b3b 100644 --- a/common.sh +++ b/common.sh @@ -49,19 +49,13 @@ export VM_EXTRADISKS=${VM_EXTRADISKS:-"false"} export RHCOS_INSTALLER_IMAGE_URL="https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/ootpa/410.8.20190520.0/" export RHCOS_IMAGE_URL=${RHCOS_IMAGE_URL:-${RHCOS_INSTALLER_IMAGE_URL}} - -export RHCOS_IMAGE_FILENAME_OPENSTACK_GZ="$(curl ${RHCOS_IMAGE_URL}/meta.json | jq -r '.images.openstack.path')" -export RHCOS_IMAGE_NAME=$(echo $RHCOS_IMAGE_FILENAME_OPENSTACK_GZ | sed -e 's/-openstack.*//') -# FIXME(shardy) - we need to download the -openstack as its needed -# for the baremetal nodes so we get config drive support, -# or perhaps a completely new image? -export RHCOS_IMAGE_FILENAME_OPENSTACK="${RHCOS_IMAGE_NAME}-openstack.qcow2" -export RHCOS_IMAGE_FILENAME_COMPRESSED="${RHCOS_IMAGE_NAME}-compressed.qcow2" export RHCOS_IMAGE_FILENAME_LATEST="rhcos-ootpa-latest.qcow2" # Ironic vars export IRONIC_IMAGE=${IRONIC_IMAGE:-"quay.io/metal3-io/ironic:master"} export IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"quay.io/metal3-io/ironic-inspector:master"} +export IPA_DOWNLOADER_IMAGE=${IPA_DOWNLOADER_IMAGE:-"quay.io/higginsd/resource-downloader-ipa:master"} +export COREOS_DOWNLOADER_IMAGE=${COREOS_DOWNLOADER_IMAGE:-"quay.io/higginsd/resource-downloader-coreos:master"} export IRONIC_DATA_DIR="$WORKING_DIR/ironic" export KUBECONFIG="${SCRIPTDIR}/ocp/auth/kubeconfig" diff --git a/get_images.sh b/get_images.sh deleted file mode 100755 index 0ec3f2a49..000000000 --- a/get_images.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -set -xe - -source common.sh - -mkdir -p "$IRONIC_DATA_DIR/html/images" -pushd "$IRONIC_DATA_DIR/html/images" -if [ ! -f "${RHCOS_IMAGE_FILENAME_OPENSTACK}" ]; then - curl --insecure --compressed -L -o "${RHCOS_IMAGE_FILENAME_OPENSTACK}" "${RHCOS_IMAGE_URL}/${RHCOS_IMAGE_FILENAME_OPENSTACK}" -fi - -initramfs="ironic-python-agent.initramfs" -initramfs_min_date=$(date -d "June 4, 2019" +%s) -initramfs_date=0 -if [ -f $initramfs ]; then - initramfs_date=$(date +%s -r ironic-python-agent.initramfs) -fi - -if [ ! -f $initramfs ] || [ $initramfs_date -lt $initramfs_min_date ]; then - curl --insecure --compressed -L https://images.rdoproject.org/master/rdo_trunk/current-tripleo-rdo/ironic-python-agent.tar | tar --overwrite -xf - -fi - -popd