Skip to content

Commit c1eae70

Browse files
AGENT-1134: Dev-scripts support to build OVE ISO
- Builds agent ISO without registry. - Sets rendezvousIP automatically through TUI. - Verifies UI is running and accesible. To test, set as below export AGENT_E2E_TEST_BOOT_MODE=ISO_NO_REGISTRY export AGENT_E2E_TEST_SCENARIO=SNO_IPV4 make agent_iso_no_registry ISO will be created at ocp/ostest/iso_builder/<OCP_VERSION>/ove/output/agent-ove.x86_64.iso
1 parent 64fdadb commit c1eae70

10 files changed

+277
-88
lines changed

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ agent: agent_requirements requirements configure agent_build_installer agent_pre
1313
# Requires at least 1 extra worker node to be configured with disk size at least 100Gß
1414
agent_plus_add_node: agent agent_add_extraworker_nodes
1515

16+
# Create an agent (OVE) ISO that includes agent-tui, assisted-install-ui, and release images,
17+
# enabling cluster installation in disconnected environments without requiring a registry.
18+
# TODO: Enhance agent_create_cluster to programmatically interact with the UI to initiate cluster installation.
19+
# Currently, agent_create_cluster boots the agent OVE ISO, configures the rendezvousIP and verifies if UI is running.
20+
agent_iso_no_registry: agent_requirements requirements configure agent_clone_agent_installer_utils agent_create_cluster
21+
1622
agent_requirements:
1723
./agent/01_agent_requirements.sh
1824

@@ -46,6 +52,9 @@ agent_remove_extraworker_nodes:
4652
agent_post_install_validation:
4753
./agent/agent_post_install_validation.sh
4854

55+
agent_clone_agent_installer_utils:
56+
./agent/08_agent_clone_agent_installer_utils.sh
57+
4958
redeploy: ocp_cleanup ironic_cleanup build_installer ironic install_config ocp_run bell
5059

5160
requirements:

agent/01_agent_requirements.sh

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISCSI" ]]; then
5050
# Install shell to administer local storage
5151
sudo dnf -y install targetcli
5252
fi
53+
54+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" == "ISO_NO_REGISTRY" ]]; then
55+
sudo dnf -y install xorriso coreos-installer
56+
fi

agent/06_agent_create_cluster.sh

+78-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ source $SCRIPTDIR/validation.sh
1212
source $SCRIPTDIR/release_info.sh
1313
source $SCRIPTDIR/agent/common.sh
1414
source $SCRIPTDIR/agent/iscsi_utils.sh
15+
source $SCRIPTDIR/agent/e2e/agent-tui/utils.sh
1516

1617
early_deploy_validation
1718

@@ -80,6 +81,15 @@ function create_config_image() {
8081
cp -r ${config_image_dir}/auth ${asset_dir}
8182
}
8283

84+
function create_agent_iso_no_registry() {
85+
# Create agent ISO without registry a.k.a. OVE ISO
86+
local asset_dir=${1}
87+
pushd .
88+
cd $OPENSHIFT_AGENT_INSTALER_UTILS_PATH/tools/iso_builder
89+
./hack/build-ove-image.sh --pull-secret-file "${PULL_SECRET_FILE}" --release-image-url "${OPENSHIFT_RELEASE_IMAGE}" --dir "${asset_dir}"
90+
popd
91+
}
92+
8393
function set_device_config_image() {
8494

8595
for (( n=0; n<${2}; n++ ))
@@ -152,6 +162,40 @@ function attach_appliance_diskimage() {
152162
done
153163
}
154164

165+
function attach_agent_iso_no_registry() {
166+
set_file_acl
167+
168+
local base_dir=$SCRIPTDIR/$OCP_DIR
169+
local iso_name="agent-ove.$(uname -p).iso"
170+
local agent_iso_no_registry=$(find "$base_dir" -type f -name "$iso_name" 2>/dev/null | head -n 1)
171+
172+
for (( n=0; n<${2}; n++ ))
173+
do
174+
name=${CLUSTER_NAME}_${1}_${n}
175+
sudo virt-xml ${name} --add-device --disk "${agent_iso_no_registry}",device=cdrom,target.dev=sdc
176+
sudo virt-xml ${name} --edit target=sda --disk="boot_order=1"
177+
sudo virt-xml ${name} --edit target=sdc --disk="boot_order=2" --start
178+
echo "Waiting for 3 mins to arrive at agent-tui screen"
179+
sleep 180
180+
./agent/e2e/agent-tui/test-no-registry-agent-tui.sh $name
181+
echo "Finished configuring the rendezvousIP via agent-tui for $name"
182+
done
183+
}
184+
185+
function check_assisted_install_UI(){
186+
local rendezvousIP=$(getRendezvousIP)
187+
local url="http://$rendezvousIP:3001"
188+
while true; do
189+
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "^200$"; then
190+
echo "Assisted install UI is up: $url"
191+
break
192+
else
193+
echo "Assisted install UI not ready, retrying in 5 seconds..."
194+
sleep 5
195+
fi
196+
done
197+
}
198+
155199
function get_node0_ip() {
156200
node0_name=$(printf ${MASTER_HOSTNAME_FORMAT} 0)
157201
node0_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node0_name}']/../@ip)" -)
@@ -435,9 +479,11 @@ function put_operator_file() {
435479
ssh "${ssh_opts[@]}" "sudo cp /home/core/operators.yaml /etc/assisted/manifests/."
436480
}
437481

438-
asset_dir="${1:-${OCP_DIR}}"
439-
config_image_dir="${1:-${OCP_DIR}/configimage}"
440-
openshift_install="$(realpath "${OCP_DIR}/openshift-install")"
482+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]]; then
483+
asset_dir="${1:-${OCP_DIR}}"
484+
config_image_dir="${1:-${OCP_DIR}/configimage}"
485+
openshift_install="$(realpath "${OCP_DIR}/openshift-install")"
486+
fi
441487

442488
case "${AGENT_E2E_TEST_BOOT_MODE}" in
443489
"ISO" )
@@ -499,6 +545,23 @@ case "${AGENT_E2E_TEST_BOOT_MODE}" in
499545
# (to avoid storage overconsumption on the CI machine)
500546
sudo rm -f "${OCP_DIR}/appliance.raw"
501547
;;
548+
"ISO_NO_REGISTRY" )
549+
# Build an (OVE) image which does not need registry setup
550+
# Run a script from agent-installer-utils which internally uses openshift-appliance
551+
asset_dir=$SCRIPTDIR/$OCP_DIR/iso_builder
552+
mkdir -p ${asset_dir}
553+
create_agent_iso_no_registry ${asset_dir}
554+
555+
attach_agent_iso_no_registry master $NUM_MASTERS
556+
attach_agent_iso_no_registry worker $NUM_WORKERS
557+
558+
# In case of SNO, wait for additional 3 minutes for the node
559+
# to finish booting up and make sure UI is up
560+
if [[ "${NUM_MASTERS}" == "1" ]]; then
561+
sleep 180
562+
fi
563+
check_assisted_install_UI
564+
;;
502565
esac
503566

504567
if [ ! -z "${AGENT_TEST_CASES:-}" ]; then
@@ -528,17 +591,24 @@ if [[ ! -z $AGENT_OPERATORS ]]; then
528591
put_operator_file
529592
fi
530593

531-
wait_for_cluster_ready
594+
# Current goal is to only verify if the nodes are booted fine,
595+
# TUI sets the rendezvous IP correctly and UI is accessible.
596+
# The next goal is to simulate adding the cluster details via UI
597+
# and complete the cluster installation.
598+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]]; then
599+
wait_for_cluster_ready
600+
fi
532601

533602
if [ ! -z "${AGENT_DEPLOY_MCE}" ]; then
534603
mce_complete_deployment
535604
fi
536605

537606
# e2e test configuration
538-
539-
# Configure storage for the image registry
540-
oc patch configs.imageregistry.operator.openshift.io \
541-
cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}},"managementState":"Managed"}}'
607+
if [[ "${AGENT_E2E_TEST_BOOT_MODE}" != "ISO_NO_REGISTRY" ]]; then
608+
# Configure storage for the image registry
609+
oc patch configs.imageregistry.operator.openshift.io \
610+
cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}},"managementState":"Managed"}}'
611+
fi
542612

543613
if [[ ! -z "${ENABLE_LOCAL_REGISTRY}" ]]; then
544614
# Configure tools image registry and cluster samples operator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
set -e
4+
5+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
6+
7+
LOGDIR=${SCRIPTDIR}/logs
8+
source $SCRIPTDIR/logging.sh
9+
source common.sh
10+
source utils.sh
11+
source ocp_install_env.sh
12+
source validation.sh
13+
14+
function clone_agent_installer_utils() {
15+
# Clone repo, if not already present
16+
if [[ ! -d $OPENSHIFT_AGENT_INSTALER_UTILS_PATH ]]; then
17+
sync_repo_and_patch go/src/github.com/openshift/agent-installer-utils https://github.com/openshift/agent-installer-utils.git
18+
fi
19+
}
20+
21+
early_deploy_validation
22+
23+
write_pull_secret
24+
25+
# Extract an updated client tools from the release image
26+
extract_oc "${OPENSHIFT_RELEASE_IMAGE}"
27+
28+
clone_agent_installer_utils

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/e2e/agent-tui/test-fix-wrong-dns.sh

+4-77
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,15 @@
11
#!/bin/bash
22

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

69
CLUSTER_NAME=$1
710
GOOD_DNS_IP=$2
811
OCP_VERSION=$3
912

10-
### utils function for sending various keys and/or text to the console
11-
12-
function _pressKey() {
13-
local keyCode=$@
14-
15-
name=${CLUSTER_NAME}_master_0
16-
sudo virsh send-key $name $keyCode
17-
18-
# On some CI instances, the sequence of events appears to be too fast
19-
# for the console refresh, leading the test in the wrong state.
20-
# Let's add a small pause between one keypress event and the subsequent
21-
sleep 1
22-
}
23-
24-
function pressKey() {
25-
local msg=$1
26-
local keyCode=$2
27-
local numReps=1
28-
29-
if [ ! -z "$3" ]; then
30-
numReps=$3
31-
echo "$msg ($numReps)"
32-
else
33-
echo $msg
34-
fi
35-
36-
for i in $(seq 1 $numReps); do
37-
_pressKey $keyCode
38-
done
39-
}
40-
41-
function pressEnter() {
42-
pressKey "$1" KEY_ENTER "$2"
43-
}
44-
45-
function pressTab() {
46-
pressKey "$1" KEY_TAB "$2"
47-
}
48-
49-
function pressDown() {
50-
pressKey "$1" KEY_DOWN "$2"
51-
}
52-
53-
function pressBackspace() {
54-
pressKey "$1" KEY_BACKSPACE "$2"
55-
}
56-
57-
58-
function pressEsc() {
59-
pressKey "$1" KEY_ESC "$2"
60-
}
61-
62-
function pressKeys(){
63-
local msg=$1
64-
local text=$2
65-
66-
echo $msg
67-
68-
local reNumber='[0-9]'
69-
local reUpperText='[A-Z]'
70-
for (( i=0; i<${#text}; i++ )); do
71-
local c=${text:$i:1}
72-
73-
if [[ $c =~ ['a-z'] ]]; then
74-
c=$(echo $c | tr '[:lower:]' '[:upper:]')
75-
elif [[ $c =~ ['\.'] ]]; then
76-
c="DOT"
77-
elif [[ $c =~ [':'] ]]; then
78-
c="LEFTSHIFT KEY_SEMICOLON"
79-
fi
80-
81-
local keyCode="KEY_"$c
82-
_pressKey $keyCode
83-
done
84-
}
85-
8613
### Prereq: create an agent ISO using an incorrect DNS address in the agent-config.yaml
8714
### This can be done by setting AGENT_E2E_TEST_TUI_BAD_DNS to true in config_<user>.sh
8815

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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" == "${CLUSTER_NAME}_master_0" ]]; then
15+
pressDown "Save Rendezvous IP" 1
16+
pressDown "Designate this node as the Rendezvous node by selecting one of its IPs" 1
17+
pressEnter "Designate this node as the Rendezvous node by selecting one of its IPs"
18+
pressEnter ""
19+
pressEnter "Continue with installation"
20+
else
21+
# Since master_0 is the first node to boot and is correctly set as the rendezvous node,
22+
# this else block retrieves the rendezvousIP and automatically inputs it into the TUI text field
23+
# on all other nodes to ensure proper cluster joining.
24+
rendezvousIP=$(getRendezvousIP)
25+
26+
typeIPAddress "Entering IP address" "$rendezvousIP" "$node_name"
27+
pressDown "Save Rendezvous IP" 1 "$node_name"
28+
pressEnter "" "" "$node_name"
29+
pressEnter "Continue with installation" "" "$node_name"
30+
fi

0 commit comments

Comments
 (0)