Skip to content

AGENT-1134: Dev-scripts support to build OVE ISO #1745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions agent/01_agent_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ set -o pipefail

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

LOGDIR=${SCRIPTDIR}/logs
source $SCRIPTDIR/logging.sh
source $SCRIPTDIR/common.sh
source $SCRIPTDIR/agent/common.sh
source $SCRIPTDIR/utils.sh
source $SCRIPTDIR/ocp_install_env.sh
source $SCRIPTDIR/validation.sh

early_deploy_validation

function clone_agent_installer_utils() {
# Clone repo, if not already present
if [[ ! -d $OPENSHIFT_AGENT_INSTALER_UTILS_PATH ]]; then
sync_repo_and_patch go/src/github.com/openshift/agent-installer-utils https://github.com/openshift/agent-installer-utils.git
fi
}

if [[ -z ${AGENT_E2E_TEST_SCENARIO} ]]; then
printf "\nAGENT_E2E_TEST_SCENARIO is missing or empty. Did you forget to set the AGENT_E2E_TEST_SCENARIO env var in the config_<USER>.sh file?"
invalidAgentValue
Expand Down Expand Up @@ -50,3 +60,16 @@ if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISCSI" ]]; then
# Install shell to administer local storage
sudo dnf -y install targetcli
fi

if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
sudo dnf -y install xorriso coreos-installer syslinux skopeo

early_deploy_validation

write_pull_secret

# Extract an updated client tools from the release image
extract_oc "${OPENSHIFT_RELEASE_IMAGE}"

clone_agent_installer_utils
fi
5 changes: 5 additions & 0 deletions agent/03_agent_build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ source $SCRIPTDIR/logging.sh
source $SCRIPTDIR/common.sh
source $SCRIPTDIR/agent/common.sh

# Temporarily skip building the agent installer in case of OVE ISO
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
exit 0
fi

# Override build tags
export OPENSHIFT_INSTALLER_BUILD_TAGS=" "

Expand Down
5 changes: 5 additions & 0 deletions agent/04_agent_prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ source $SCRIPTDIR/agent/common.sh
source $SCRIPTDIR/ocp_install_env.sh
source $SCRIPTDIR/oc_mirror.sh

# Temporarily skip preparing the custom local release in case of OVE ISO
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
exit 0
fi

# To replace an image entry in the openshift release image, set <ENTRYNAME>_LOCAL_REPO so that:
# - ENTRYNAME matches an uppercase version of the name in the release image with "-" converted to "_"
# - The var value must point to an already locally cloned repo
Expand Down
11 changes: 7 additions & 4 deletions agent/05_agent_configure.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -euxo pipefail
shopt -s nocasematch

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

Expand All @@ -14,6 +15,7 @@ source $SCRIPTDIR/agent/common.sh
source $SCRIPTDIR/oc_mirror.sh

early_deploy_validation
mkdir -p $OCP_DIR

export CLUSTER_NAMESPACE=${CLUSTER_NAMESPACE:-"cluster0"}

Expand Down Expand Up @@ -619,10 +621,11 @@ if [[ "${AGENT_PLATFORM_TYPE}" == "external" ]] || [[ "${AGENT_PLATFORM_TYPE}" =
set_device_mfg worker $NUM_WORKERS ${AGENT_PLATFORM_TYPE} ${AGENT_PLATFORM_NAME}
fi

generate_cluster_manifests
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]] ; then
generate_cluster_manifests

generate_extra_cluster_manifests

write_extra_workers_ips
generate_extra_cluster_manifests

write_extra_workers_ips
fi
enable_isolated_baremetal_network
119 changes: 116 additions & 3 deletions agent/06_agent_create_cluster.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -euxo pipefail
shopt -s nocasematch

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

Expand All @@ -12,6 +13,7 @@ source $SCRIPTDIR/validation.sh
source $SCRIPTDIR/release_info.sh
source $SCRIPTDIR/agent/common.sh
source $SCRIPTDIR/agent/iscsi_utils.sh
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh

early_deploy_validation

Expand Down Expand Up @@ -80,6 +82,38 @@ function create_config_image() {
cp -r ${config_image_dir}/auth ${asset_dir}
}

function create_agent_iso_no_registry() {
# Create agent ISO without registry a.k.a. OVE ISO
local asset_dir=${1}
pushd .
cd $OPENSHIFT_AGENT_INSTALER_UTILS_PATH/tools/iso_builder
./hack/build-ove-image.sh --pull-secret-file "${PULL_SECRET_FILE}" --release-image-url "${OPENSHIFT_RELEASE_IMAGE}" --ssh-key-file "${SSH_KEY_FILE}" --dir "${asset_dir}"
popd
}

# Deletes all files and directories under asset_dir
# example, ocp/ostest/iso_builder/4.19.*
# except the final generated ISO file (agent-ove.x86_64.iso),
# to free up disk space while preserving the built artifact.
# Note: This optional cleanup is relevant only when the
# AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV is set as as true,
function cleanup_diskspace_agent_iso_noregistry() {
local asset_dir=${1%/} # Remove trailing slash if present

# Iterate over all versioned directories matching 4.19.*
for dir in "$asset_dir"/4.19.*; do
[ -d "$dir" ] || continue

echo "Cleaning up directory: $dir"

# Delete all files and symlinks except the agent-ove.x86_64.iso
sudo find "$dir" \( -type f -o -type l \) ! -name 'agent-ove.x86_64.iso' -print -delete

# Remove any empty directories left behind
sudo find "$dir" -type d -empty -print -delete
done
}

function set_device_config_image() {

for (( n=0; n<${2}; n++ ))
Expand Down Expand Up @@ -152,6 +186,52 @@ function attach_appliance_diskimage() {
done
}

function attach_agent_iso_no_registry() {
set_file_acl

local base_dir=$SCRIPTDIR/$OCP_DIR
local iso_name="agent-ove.$(uname -p).iso"
local agent_iso_no_registry=$(find "$base_dir" -type f -name "$iso_name" 2>/dev/null | head -n 1)

for (( n=0; n<${2}; n++ ))
do
name=${CLUSTER_NAME}_${1}_${n}
sudo virt-xml ${name} --add-device --disk "${agent_iso_no_registry}",device=cdrom,target.dev=sdc
sudo virt-xml ${name} --edit target=sda --disk="boot_order=1"
sudo virt-xml ${name} --edit target=sdc --disk="boot_order=2" --start
done
}

function automate_rendezvousIP_selection(){
for (( n=0; n<${2}; n++ ))
do
name=${CLUSTER_NAME}_${1}_${n}
# Take screenshots of console before running the automation that configures the rendezvousIP.
# The screenshot may help us see if agent-tui has reached the expected success state.
sudo virsh screenshot $name "${OCP_DIR}/${name}_console_screenshot_before_automation_configures_rendezvousIP.ppm"

./agent/e2e/agent-tui/automate-no-registry-agent-tui.sh $name

# Take screenshot of the console after running the automation that configures the rendezvousIP.
sudo virsh screenshot $name "${OCP_DIR}/${name}_console_screenshot_after_automation_configures_rendezvousIP.ppm"
echo "Finished configuring the rendezvousIP via agent-tui for $name"
done
}

function check_assisted_install_UI(){
local rendezvousIP=$(getRendezvousIP)
local url="http://$rendezvousIP:3001"
while true; do
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "^200$"; then
echo "Assisted install UI is up: $url"
break
else
echo "Assisted install UI not ready, retrying in 30 seconds..."
sleep 30
fi
done
}

function get_node0_ip() {
node0_name=$(printf ${MASTER_HOSTNAME_FORMAT} 0)
node0_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node0_name}']/../@ip)" -)
Expand Down Expand Up @@ -435,9 +515,11 @@ function put_operator_file() {
ssh "${ssh_opts[@]}" "sudo cp /home/core/operators.yaml /etc/assisted/manifests/."
}

asset_dir="${1:-${OCP_DIR}}"
config_image_dir="${1:-${OCP_DIR}/configimage}"
openshift_install="$(realpath "${OCP_DIR}/openshift-install")"
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]]; then
asset_dir="${1:-${OCP_DIR}}"
config_image_dir="${1:-${OCP_DIR}/configimage}"
openshift_install="$(realpath "${OCP_DIR}/openshift-install")"
fi

case "${AGENT_E2E_TEST_BOOT_MODE}" in
"ISO" )
Expand Down Expand Up @@ -499,8 +581,38 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in
# (to avoid storage overconsumption on the CI machine)
sudo rm -f "${OCP_DIR}/appliance.raw"
;;
"ISO_NO_REGISTRY" )
# Build an (OVE) image which does not need registry setup
# Run a script from agent-installer-utils which internally uses openshift-appliance
asset_dir=$SCRIPTDIR/$OCP_DIR/iso_builder
mkdir -p ${asset_dir}
create_agent_iso_no_registry ${asset_dir}

if [[ "$AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV" == "true" ]]; then
# reclaim disk space by deleting unwanted cache, other files
cleanup_diskspace_agent_iso_noregistry ${asset_dir}
fi

attach_agent_iso_no_registry master $NUM_MASTERS
attach_agent_iso_no_registry worker $NUM_WORKERS

echo "Waiting for 2 mins to arrive at agent-tui screen"
sleep 120
automate_rendezvousIP_selection master $NUM_MASTERS
automate_rendezvousIP_selection worker $NUM_WORKERS

check_assisted_install_UI
;;
esac

if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
# Current goal is to only verify if the nodes are booted fine,
# TUI sets the rendezvous IP correctly and UI is accessible.
# The next goal is to simulate adding the cluster details via UI
# and complete the cluster installation.
exit 0
fi

if [ ! -z "${AGENT_TEST_CASES:-}" ]; then
run_agent_test_cases
fi
Expand Down Expand Up @@ -528,6 +640,7 @@ if [[ ! -z $AGENT_OPERATORS ]]; then
put_operator_file
fi


wait_for_cluster_ready

if [ ! -z "${AGENT_DEPLOY_MCE}" ]; then
Expand Down
5 changes: 5 additions & 0 deletions agent/agent_post_install_validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

source $SCRIPTDIR/common.sh

# Temp code skip the execution flow as cluster is not really installed
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
exit 0
fi

installed_control_plane_nodes=$(oc get nodes --selector=node-role.kubernetes.io/master | grep -v AGE | wc -l)

oc get nodes
Expand Down
6 changes: 6 additions & 0 deletions agent/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ export AGENT_NODE0_IPSV6=${AGENT_NODE0_IPSV6:-}

# Modifies the baremetal network to be fully isolated.
export AGENT_ISOLATED_NETWORK=${AGENT_ISOLATED_NETWORK:-"false"}

# Set isolated network to true for truely disconnected OVE env
# in case of agent ISO with no registry
if [ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ] ; then
export AGENT_ISOLATED_NETWORK=true
fi
29 changes: 29 additions & 0 deletions agent/e2e/agent-tui/automate-no-registry-agent-tui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../" && pwd )"
source $SCRIPTDIR/common.sh
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh

set +x
shopt -s nocasematch

node_name=$1

# The following commands sends key presses through "virsh send-key" to interact
# with agent-tui
if [[ "$node_name" == "${AGENT_RENDEZVOUS_NODE_HOSTNAME}" ]]; then
pressDown "Save Rendezvous IP" 1 "$node_name"
pressDown "This is the rendezvous node" 1 "$node_name"
pressEnter "This is the rendezvous node" "" "$node_name"
pressEnter "" "" "$node_name"
pressEnter "Continue" "" "$node_name"
else
# Retrieves the rendezvousIP and automatically inputs it into the TUI text field
# on all other nodes to ensure proper cluster joining.
rendezvousIP=$(getRendezvousIP)

pressKeys "Entering IP address" "$rendezvousIP" "$node_name"
pressDown "Save Rendezvous IP" 1 "$node_name"
pressEnter "" "" "$node_name"
pressEnter "Save and Continue" "" "$node_name"
fi
3 changes: 1 addition & 2 deletions agent/e2e/agent-tui/test-fix-wrong-dns.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../.." && pwd )"

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../" && pwd )"
source $SCRIPTDIR/common.sh
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh
set +x
Expand Down
Loading