From 0ff1d633cdd3485dfe29b46ebfcf82b168a85a51 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Thu, 12 Aug 2021 16:40:41 -0600 Subject: [PATCH] Make Hook the default OSIE: With the recent update in Hook to publish the kernel and initrd we can make make hook the default in the sandbox. Original OSIE can still be used by updating deploy/compose/.env and setting OSIE_DOWNLOAD_URL to an OSIE URL and TINKERBELL_USE_HOOK to false. Currently only an x86_64 Hook is published so only x86_64 machines can be provisioned with the sandbox using Hook. Signed-off-by: Jacob Weinstock --- deploy/compose/.env | 4 ++- deploy/compose/docker-compose.yml | 9 +++++- deploy/compose/osie/lastmile.sh | 36 +++++++++++++++++---- deploy/compose/registry/registry_images.txt | 1 + 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/deploy/compose/.env b/deploy/compose/.env index 126ec6a..5ad163e 100644 --- a/deploy/compose/.env +++ b/deploy/compose/.env @@ -1,4 +1,6 @@ -OSIE_DOWNLOAD_URL="https://tinkerbell-oss.s3.amazonaws.com/osie-uploads/osie-1790-23d78ea47f794d0e5c934b604579c26e5fce97f5.tar.gz" +#OSIE_DOWNLOAD_URL="https://tinkerbell-oss.s3.amazonaws.com/osie-uploads/osie-1790-23d78ea47f794d0e5c934b604579c26e5fce97f5.tar.gz" +OSIE_DOWNLOAD_URL="https://github.com/tinkerbell/hook/releases/download/5.10.57/hook-x86_64.tar.gz" +TINKERBELL_USE_HOOK="true" TINK_CLI_IMAGE="quay.io/tinkerbell/tink-cli:sha-8ea8a0e5" TINK_SERVER_IMAGE="quay.io/tinkerbell/tink:sha-8ea8a0e5" BOOTS_SERVER_IMAGE="quay.io/tinkerbell/boots:sha-94f43947" diff --git a/deploy/compose/docker-compose.yml b/deploy/compose/docker-compose.yml index 5b5d233..848963d 100644 --- a/deploy/compose/docker-compose.yml +++ b/deploy/compose/docker-compose.yml @@ -29,7 +29,14 @@ services: osie-work: image: alpine entrypoint: /scripts/lastmile.sh - command: ["${OSIE_DOWNLOAD_URL}", "/source", "/source", "/destination"] + command: + [ + "${OSIE_DOWNLOAD_URL}", + "/source", + "/source", + "/destination", + "${TINKERBELL_USE_HOOK}", + ] volumes: - ${REPO_TOP_LEVEL:-.}/osie:/scripts - ${REPO_TOP_LEVEL:-.}/state/webroot/misc/osie/current:/source diff --git a/deploy/compose/osie/lastmile.sh b/deploy/compose/osie/lastmile.sh index 694b60b..705b2db 100755 --- a/deploy/compose/osie/lastmile.sh +++ b/deploy/compose/osie/lastmile.sh @@ -24,12 +24,25 @@ osie_move_helper_scripts() { cp "${source_dir}"/workflow-helper.sh "${source_dir}"/workflow-helper-rc "${dest_dir}"/ } +# hook_rename_files renames the kernel and initrd files from the github downloaded tar +# to the default names that the OSIE installer in Boots is expecting. +# See https://github.com/tinkerbell/boots/blob/78d4f74e6944ae3bd04e1297dc8e354fc93d9320/installers/osie/main.go#L160 and +# https://github.com/tinkerbell/boots/blob/78d4f74e6944ae3bd04e1297dc8e354fc93d9320/installers/osie/main.go#L168 +hook_rename_files() { + local src_kernel="$1" + local src_initrd="$2" + local dest_dir="$3" + mv "${src_kernel}" "${dest_dir}/vmlinuz-x86_64" + mv "${src_initrd}" "${dest_dir}/initramfs-x86_64" +} + # main runs the functions in order to download, extract, and move helper scripts main() { local url="$1" local extract_dir="$2" local source_dir="$3" local dest_dir="$4" + local use_hook="$5" if [ ! -f "${extract_dir}"/osie.tar.gz ]; then echo "downloading osie..." @@ -37,13 +50,24 @@ main() { else echo "osie already downloaded" fi - if [ ! -f "${source_dir}"/workflow-helper.sh ] && [ ! -f "${source_dir}"/workflow-helper-rc ]; then - echo "extracting osie..." - osie_extract "${extract_dir}" "${source_dir}" + + if [ "${use_hook}" == "true" ]; then + if [ ! -f "${source_dir}"/hook-x86_64-kernel ] && [ ! -f "${source_dir}"/hook-x86_64-initrd.img ]; then + echo "extracting hook..." + osie_extract "${extract_dir}" "${source_dir}" + else + echo "hook files already exist, not extracting" + fi + hook_rename_files "${source_dir}"/hook-x86_64-kernel "${source_dir}"/hook-x86_64-initrd.img "${source_dir}" else - echo "osie files already exist, not extracting" + if [ ! -f "${source_dir}"/workflow-helper.sh ] && [ ! -f "${source_dir}"/workflow-helper-rc ]; then + echo "extracting osie..." + osie_extract "${extract_dir}" "${source_dir}" + else + echo "osie files already exist, not extracting" + fi + osie_move_helper_scripts "${source_dir}" "${dest_dir}" fi - osie_move_helper_scripts "${source_dir}" "${dest_dir}" } -main "$1" "$2" "$3" "$4" +main "$1" "$2" "$3" "$4" "$5" diff --git a/deploy/compose/registry/registry_images.txt b/deploy/compose/registry/registry_images.txt index 02a9ebe..036e710 100644 --- a/deploy/compose/registry/registry_images.txt +++ b/deploy/compose/registry/registry_images.txt @@ -1,4 +1,5 @@ quay.io/tinkerbell/tink-worker:latest tinkerbell/tink-worker:latest +quay.io/tinkerbell/tink-worker:latest tink-worker:latest quay.io/tinkerbell/tink-worker:latest tinkerbell/tink-worker:sha-5e1f0fd8 quay.io/tinkerbell-actions/image2disk:v1.0.0 image2disk:v1.0.0 quay.io/tinkerbell-actions/cexec:v1.0.0 cexec:v1.0.0