Skip to content

Commit f6a85d6

Browse files
AGENT-1134: Dev-scripts support to build OVE ISO
- Reuse `make agent` target (instead of introducing a new one) - Build agent OVE ISO - Boot up the required VMs - Set custom rendezvous node (Use AGENT_RENDEZVOUS_NODE_HOSTNAME) and auto-configure rendezvousIP via TUI - Take TUI screenshots during install flow - Verify that the assisted install web UI is running and accessible - Reclaim disk space by cleaning up cache and unnecessary files (Use AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV for local/dev testing) - Increase VCPU allocation for certain operators requiring more resources - Install required dependencies - Temporarily skip common steps not relevant for OVE ISO installs - Temporarily skip generating unused manifests and config files To test, set as below export AGENT_E2E_TEST_BOOT_MODE=ISO_NO_REGISTRY export AGENT_E2E_TEST_SCENARIO=COMPACT_IPV4 export AGENT_RENDEZVOUS_NODE_HOSTNAME="${CLUSTER_NAME:-ostest}_master_1" export AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV=true make agent ISO will be created at ocp/ostest/iso_builder/<OCP_VERSION>/ove/output/agent-ove.x86_64.iso
1 parent 4035a38 commit f6a85d6

14 files changed

+270
-25
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ agent_remove_extraworker_nodes:
4646
agent_post_install_validation:
4747
./agent/agent_post_install_validation.sh
4848

49+
4950
redeploy: ocp_cleanup ironic_cleanup build_installer ironic install_config ocp_run bell
5051

5152
requirements:

agent/01_agent_requirements.sh

+23
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ set -o pipefail
44

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

7+
LOGDIR=${SCRIPTDIR}/logs
8+
source $SCRIPTDIR/logging.sh
79
source $SCRIPTDIR/common.sh
810
source $SCRIPTDIR/agent/common.sh
911
source $SCRIPTDIR/utils.sh
12+
source $SCRIPTDIR/ocp_install_env.sh
1013
source $SCRIPTDIR/validation.sh
1114

1215
early_deploy_validation
1316

17+
function clone_agent_installer_utils() {
18+
# Clone repo, if not already present
19+
if [[ ! -d $OPENSHIFT_AGENT_INSTALER_UTILS_PATH ]]; then
20+
sync_repo_and_patch go/src/github.com/openshift/agent-installer-utils https://github.com/openshift/agent-installer-utils.git
21+
fi
22+
}
23+
1424
if [[ -z ${AGENT_E2E_TEST_SCENARIO} ]]; then
1525
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?"
1626
invalidAgentValue
@@ -50,3 +60,16 @@ if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISCSI" ]]; then
5060
# Install shell to administer local storage
5161
sudo dnf -y install targetcli
5262
fi
63+
64+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
65+
sudo dnf -y install xorriso coreos-installer syslinux skopeo
66+
67+
early_deploy_validation
68+
69+
write_pull_secret
70+
71+
# Extract an updated client tools from the release image
72+
extract_oc "${OPENSHIFT_RELEASE_IMAGE}"
73+
74+
clone_agent_installer_utils
75+
fi

agent/03_agent_build_installer.sh

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ source $SCRIPTDIR/logging.sh
88
source $SCRIPTDIR/common.sh
99
source $SCRIPTDIR/agent/common.sh
1010

11+
# Temporarily skip building the agent installer in case of OVE ISO
12+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
13+
exit 0
14+
fi
15+
1116
# Override build tags
1217
export OPENSHIFT_INSTALLER_BUILD_TAGS=" "
1318

agent/04_agent_prepare_release.sh

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ source $SCRIPTDIR/agent/common.sh
1313
source $SCRIPTDIR/ocp_install_env.sh
1414
source $SCRIPTDIR/oc_mirror.sh
1515

16+
# Temporarily skip preparing the custom local release in case of OVE ISO
17+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
18+
exit 0
19+
fi
20+
1621
# To replace an image entry in the openshift release image, set <ENTRYNAME>_LOCAL_REPO so that:
1722
# - ENTRYNAME matches an uppercase version of the name in the release image with "-" converted to "_"
1823
# - The var value must point to an already locally cloned repo

agent/05_agent_configure.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
set -euxo pipefail
3+
shopt -s nocasematch
34

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

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

1617
early_deploy_validation
18+
mkdir -p $OCP_DIR
1719

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

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

622-
generate_cluster_manifests
624+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]] ; then
625+
generate_cluster_manifests
623626

624-
generate_extra_cluster_manifests
625-
626-
write_extra_workers_ips
627+
generate_extra_cluster_manifests
627628

629+
write_extra_workers_ips
630+
fi
628631
enable_isolated_baremetal_network

agent/06_agent_create_cluster.sh

+117-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
set -euxo pipefail
3+
shopt -s nocasematch
34

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

@@ -12,6 +13,7 @@ source $SCRIPTDIR/validation.sh
1213
source $SCRIPTDIR/release_info.sh
1314
source $SCRIPTDIR/agent/common.sh
1415
source $SCRIPTDIR/agent/iscsi_utils.sh
16+
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh
1517

1618
early_deploy_validation
1719

@@ -80,6 +82,39 @@ function create_config_image() {
8082
cp -r ${config_image_dir}/auth ${asset_dir}
8183
}
8284

85+
function create_agent_iso_no_registry() {
86+
# Create agent ISO without registry a.k.a. OVE ISO
87+
local asset_dir=${1}
88+
pushd .
89+
cd $OPENSHIFT_AGENT_INSTALER_UTILS_PATH/tools/iso_builder
90+
./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}"
91+
popd
92+
}
93+
94+
# Deletes all files and directories under asset_dir
95+
# example, ocp/ostest/iso_builder/4.19.*
96+
# except the final generated ISO file (agent-ove.x86_64.iso),
97+
# to free up disk space while preserving the built artifact.
98+
# Note: This optional cleanup is relevant only when the
99+
# AGENT_E2E_TEST_BOOT_MODE is set as as ISO_NO_REGISTRY,
100+
# which is supported starting from OCP version 4.19+.
101+
function cleanup_diskspace_agent_iso_noregistry() {
102+
local asset_dir=${1%/} # Remove trailing slash if present
103+
104+
# Iterate over all versioned directories matching 4.19.*
105+
for dir in "$asset_dir"/4.19.*; do
106+
[ -d "$dir" ] || continue
107+
108+
echo "Cleaning up directory: $dir"
109+
110+
# Delete all files and symlinks except the agent-ove.x86_64.iso
111+
sudo find "$dir" \( -type f -o -type l \) ! -name 'agent-ove.x86_64.iso' -print -delete
112+
113+
# Remove any empty directories left behind
114+
sudo find "$dir" -type d -empty -print -delete
115+
done
116+
}
117+
83118
function set_device_config_image() {
84119

85120
for (( n=0; n<${2}; n++ ))
@@ -152,6 +187,52 @@ function attach_appliance_diskimage() {
152187
done
153188
}
154189

190+
function attach_agent_iso_no_registry() {
191+
set_file_acl
192+
193+
local base_dir=$SCRIPTDIR/$OCP_DIR
194+
local iso_name="agent-ove.$(uname -p).iso"
195+
local agent_iso_no_registry=$(find "$base_dir" -type f -name "$iso_name" 2>/dev/null | head -n 1)
196+
197+
for (( n=0; n<${2}; n++ ))
198+
do
199+
name=${CLUSTER_NAME}_${1}_${n}
200+
sudo virt-xml ${name} --add-device --disk "${agent_iso_no_registry}",device=cdrom,target.dev=sdc
201+
sudo virt-xml ${name} --edit target=sda --disk="boot_order=1"
202+
sudo virt-xml ${name} --edit target=sdc --disk="boot_order=2" --start
203+
done
204+
}
205+
206+
function automate_rendezvousIP_selection(){
207+
for (( n=0; n<${2}; n++ ))
208+
do
209+
name=${CLUSTER_NAME}_${1}_${n}
210+
# Take screenshots of console before running the automation that configures the rendezvousIP.
211+
# The screenshot may help us see if agent-tui has reached the expected success state.
212+
sudo virsh screenshot $name "${OCP_DIR}/${name}_console_screenshot_before_automation_configures_rendezvousIP.ppm"
213+
214+
./agent/e2e/agent-tui/automate-no-registry-agent-tui.sh $name
215+
216+
# Take screenshot of the console after running the automation that configures the rendezvousIP.
217+
sudo virsh screenshot $name "${OCP_DIR}/${name}_console_screenshot_after_automation_configures_rendezvousIP.ppm"
218+
echo "Finished configuring the rendezvousIP via agent-tui for $name"
219+
done
220+
}
221+
222+
function check_assisted_install_UI(){
223+
local rendezvousIP=$(getRendezvousIP)
224+
local url="http://$rendezvousIP:3001"
225+
while true; do
226+
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "^200$"; then
227+
echo "Assisted install UI is up: $url"
228+
break
229+
else
230+
echo "Assisted install UI not ready, retrying in 30 seconds..."
231+
sleep 30
232+
fi
233+
done
234+
}
235+
155236
function get_node0_ip() {
156237
node0_name=$(printf ${MASTER_HOSTNAME_FORMAT} 0)
157238
node0_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node0_name}']/../@ip)" -)
@@ -435,9 +516,11 @@ function put_operator_file() {
435516
ssh "${ssh_opts[@]}" "sudo cp /home/core/operators.yaml /etc/assisted/manifests/."
436517
}
437518

438-
asset_dir="${1:-${OCP_DIR}}"
439-
config_image_dir="${1:-${OCP_DIR}/configimage}"
440-
openshift_install="$(realpath "${OCP_DIR}/openshift-install")"
519+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]]; then
520+
asset_dir="${1:-${OCP_DIR}}"
521+
config_image_dir="${1:-${OCP_DIR}/configimage}"
522+
openshift_install="$(realpath "${OCP_DIR}/openshift-install")"
523+
fi
441524

442525
case "${AGENT_E2E_TEST_BOOT_MODE}" in
443526
"ISO" )
@@ -499,8 +582,38 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in
499582
# (to avoid storage overconsumption on the CI machine)
500583
sudo rm -f "${OCP_DIR}/appliance.raw"
501584
;;
585+
"ISO_NO_REGISTRY" )
586+
# Build an (OVE) image which does not need registry setup
587+
# Run a script from agent-installer-utils which internally uses openshift-appliance
588+
asset_dir=$SCRIPTDIR/$OCP_DIR/iso_builder
589+
mkdir -p ${asset_dir}
590+
create_agent_iso_no_registry ${asset_dir}
591+
592+
if [[ "$AGENT_CLEANUP_ISO_BUILDER_CACHE_LOCAL_DEV" == "true" ]]; then
593+
# reclaim disk space by deleting unwanted cache, other files
594+
cleanup_diskspace_agent_iso_noregistry ${asset_dir}
595+
fi
596+
597+
attach_agent_iso_no_registry master $NUM_MASTERS
598+
attach_agent_iso_no_registry worker $NUM_WORKERS
599+
600+
echo "Waiting for 2 mins to arrive at agent-tui screen"
601+
sleep 120
602+
automate_rendezvousIP_selection master $NUM_MASTERS
603+
automate_rendezvousIP_selection worker $NUM_WORKERS
604+
605+
check_assisted_install_UI
606+
;;
502607
esac
503608

609+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
610+
# Current goal is to only verify if the nodes are booted fine,
611+
# TUI sets the rendezvous IP correctly and UI is accessible.
612+
# The next goal is to simulate adding the cluster details via UI
613+
# and complete the cluster installation.
614+
exit 0
615+
fi
616+
504617
if [ ! -z "${AGENT_TEST_CASES:-}" ]; then
505618
run_agent_test_cases
506619
fi
@@ -528,14 +641,14 @@ if [[ ! -z $AGENT_OPERATORS ]]; then
528641
put_operator_file
529642
fi
530643

644+
531645
wait_for_cluster_ready
532646

533647
if [ ! -z "${AGENT_DEPLOY_MCE}" ]; then
534648
mce_complete_deployment
535649
fi
536650

537651
# e2e test configuration
538-
539652
# Configure storage for the image registry
540653
oc patch configs.imageregistry.operator.openshift.io \
541654
cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}},"managementState":"Managed"}}'

agent/agent_post_install_validation.sh

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
55

66
source $SCRIPTDIR/common.sh
77

8+
# Temp code skip the execution flow as cluster is not really installed
9+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
10+
exit 0
11+
fi
12+
813
installed_control_plane_nodes=$(oc get nodes --selector=node-role.kubernetes.io/master | grep -v AGE | wc -l)
914

1015
oc get nodes

agent/cleanup.sh

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "DISKIMAGE" ]]; then
2929
sudo podman rmi -f ${APPLIANCE_IMAGE} || true
3030
fi
3131

32+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
33+
sudo rm -rf "${OCP_DIR}/iso_builder"
34+
fi
35+
3236
if [[ -d ${BOOT_SERVER_DIR} ]]; then
3337
sudo pkill agentpxeserver || true
3438
rm -rf ${BOOT_SERVER_DIR}

agent/common.sh

+6
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,9 @@ export AGENT_NODE0_IPSV6=${AGENT_NODE0_IPSV6:-}
7373

7474
# Modifies the baremetal network to be fully isolated.
7575
export AGENT_ISOLATED_NETWORK=${AGENT_ISOLATED_NETWORK:-"false"}
76+
77+
# Set isolated network to true for truely disconnected OVE env
78+
# in case of agent ISO with no registry
79+
if [ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ] ; then
80+
export AGENT_ISOLATED_NETWORK=true
81+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../" && pwd )"
4+
source $SCRIPTDIR/common.sh
5+
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh
6+
7+
set +x
8+
shopt -s nocasematch
9+
10+
node_name=$1
11+
12+
# The following commands sends key presses through "virsh send-key" to interact
13+
# with agent-tui
14+
if [[ "$node_name" == "${AGENT_RENDEZVOUS_NODE_HOSTNAME}" ]]; then
15+
pressDown "Save Rendezvous IP" 1 "$node_name"
16+
pressDown "This is the rendezvous node" 1 "$node_name"
17+
pressEnter "This is the rendezvous node" "" "$node_name"
18+
pressEnter "" "" "$node_name"
19+
pressEnter "Continue" "" "$node_name"
20+
else
21+
# Retrieves the rendezvousIP and automatically inputs it into the TUI text field
22+
# on all other nodes to ensure proper cluster joining.
23+
rendezvousIP=$(getRendezvousIP)
24+
25+
pressKeys "Entering IP address" "$rendezvousIP" "$node_name"
26+
pressDown "Save Rendezvous IP" 1 "$node_name"
27+
pressEnter "" "" "$node_name"
28+
pressEnter "Save and Continue" "" "$node_name"
29+
fi

agent/e2e/agent-tui/test-fix-wrong-dns.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

3-
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../.." && pwd )"
4-
3+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../" && pwd )"
54
source $SCRIPTDIR/common.sh
65
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh
6+
77
set +x
88

99
GOOD_DNS_IP=$1

0 commit comments

Comments
 (0)