Skip to content

Commit 9565999

Browse files
committed
fix(setup): Improve yq installation and handling
Add verbosity to the wget command so we can troubleshoot download failures if encountered more easily, as well as very clear and concise messaging around whether or not yq really got installed. YQ is more necessary on the remote host than the local host that runs the hyperconverged-lab script, so warn about it not getting installed locally but fail if not present on the remote host as it's a pre-requisite to running many install scripts.
1 parent 3837de4 commit 9565999

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

bin/setup-openstack.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function waitErator() {
1717
local start_time
1818
start_time=$(date +%s)
1919
local timeout_seconds=$((30 * 60)) # 30 minutes
20-
20+
2121
while [ ${#pids[@]} -gt 0 ]; do
2222
# Check for timeout
2323
local current_time
@@ -33,15 +33,15 @@ function waitErator() {
3333
echo "==== PROCESS TIMEOUT ====================================="
3434
exit 1
3535
fi
36-
36+
3737
for pid in "${!pids[@]}"; do
3838
# Check if process is still running
3939
if ! kill -0 ${pid} 2>/dev/null; then
4040
# Process finished, check exit status
4141
# Use || to prevent set -e from killing the script before we can log the failure
4242
wait ${pid} || local exit_code=$?
4343
exit_code=${exit_code:-0}
44-
44+
4545
if [ $exit_code -ne 0 ]; then
4646
echo "==== PROCESS FAILED ====================================="
4747
echo "Command: ${pid_commands[$pid]}"
@@ -57,7 +57,7 @@ function waitErator() {
5757
done
5858
sleep 1
5959
done
60-
60+
6161
echo "All processes completed successfully."
6262
}
6363

scripts/hyperconverged-lab.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@ RUN_EXTRAS=0
88
INCLUDE_LIST=()
99
EXCLUDE_LIST=()
1010

11+
# yq installation constants
12+
YQ_VERSION="v4.2.0"
13+
YQ_BINARY="yq_linux_amd64"
14+
1115
function installYq() {
12-
export VERSION=v4.2.0
13-
export BINARY=yq_linux_amd64
14-
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -q -O - | tar xz && sudo mv ${BINARY} /usr/local/bin/yq
16+
if wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz -O - | tar xz && sudo mv ${YQ_BINARY} /usr/local/bin/yq; then
17+
echo "Successfully installed yq version ${YQ_VERSION}"
18+
return 0
19+
else
20+
echo "Failed to install yq"
21+
return 1
22+
fi
1523
}
1624

1725
# Install yq locally if needed...
1826
if ! yq --version 2> /dev/null; then
1927
echo "yq is not installed. Attempting to install yq"
20-
installYq
28+
if ! installYq; then
29+
echo "[WARNING] Failed to install yq locally"
30+
fi
2131
fi
2232

2333

@@ -428,6 +438,19 @@ if [ ! -d "/etc/genestack" ]; then
428438
sudo chown \${USER}:\${USER} -R /etc/genestack
429439
fi
430440
441+
# Install yq on the remote host if not already present
442+
if ! command -v yq &> /dev/null; then
443+
echo "Installing yq on remote host..."
444+
if wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz -O - | tar xz && sudo mv ${YQ_BINARY} /usr/local/bin/yq; then
445+
echo "Successfully installed yq version ${YQ_VERSION} on remote host"
446+
else
447+
echo "Failed to install yq on remote host"
448+
exit 1
449+
fi
450+
else
451+
echo "yq already available on remote host: \$(yq --version)"
452+
fi
453+
431454
# We need to clobber the sample or else we get a bogus LB vip
432455
cat > /etc/genestack/manifests/metallb/metallb-openstack-service-lb.yml <<EOF
433456
---

0 commit comments

Comments
 (0)