Skip to content

Commit a013e20

Browse files
committed
Change how a-universe-from-seed is executed
1 parent 4ea8297 commit a013e20

File tree

3 files changed

+104
-47
lines changed

3 files changed

+104
-47
lines changed

.github/actions/aufn-test/run.sh

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
AU_FROM_SEED="true"
4+
# AU_FROM_SEED="true"
55
# OS_IMAGE="Rocky9"
6-
TAINT_REBUILD="true"
6+
# TAINT_REBUILD="true"
77

88
echo "Starting AUFN test action with:"
99
echo "AU_FROM_SEED: $AU_FROM_SEED"
@@ -88,6 +88,58 @@ EOF
8888
# echo >> failed-labs.txt
8989
}
9090

91+
function validate_universe_from_seed() {
92+
echo && echo
93+
echo "Validating Lab VMs setup..."
94+
index=0
95+
rm -f failed-labs.txt
96+
97+
while IFS= read -r line; do
98+
ip=$(echo "$line" | awk '{print $3}')
99+
name=$(echo "$line" | awk '{print $2}')
100+
password=$(echo "$line" | awk '{print $5}')
101+
102+
echo && echo
103+
echo "Validating $name at $ip..." && echo
104+
105+
sshpass -p "$password" ssh -o StrictHostKeyChecking=no\
106+
"lab@${ip}" <<'EOF'
107+
output=$(sudo virsh list --all)
108+
echo "$output"
109+
if ! echo "$output" | grep -q 'seed.*running'; then echo "'seed' not running"; fi
110+
if ! echo "$output" | grep -q 'compute0.*running'; then echo "'compute0' not running"; fi
111+
if ! echo "$output" | grep -q 'controller0.*running'; then echo "'controller0' not running"; fi
112+
113+
echo && echo
114+
echo "$(ssh stack@192.168.33.5 'sudo docker ps')"
115+
if ! ssh stack@192.168.33.5 'sudo docker ps' | grep -q bifrost_deploy; then echo "Bifrost container isn't deployed"; fi
116+
if ! tail -n 1 a-universe-from-seed.out | grep -q 'demo1'; then echo "There was an error in running 'a-universe-from-seed'"; fi
117+
EOF
118+
119+
set +e
120+
121+
sshpass -p "$password" ssh -o StrictHostKeyChecking=no \
122+
"lab@${ip}" <<'EOF'
123+
output=$(sudo virsh list --all)
124+
if ! echo "$output" | grep -q 'seed.*running'; then exit 1; fi
125+
if ! echo "$output" | grep -q 'compute0.*running'; then exit 1; fi
126+
if ! echo "$output" | grep -q 'controller0.*running'; then exit 1; fi
127+
128+
if ! ssh stack@192.168.33.5 'sudo docker ps' | grep -q bifrost_deploy; then exit 1; fi
129+
if ! tail -n 1 a-universe-from-seed.out | grep -q 'demo1'; then exit 1; fi
130+
131+
exit 0
132+
EOF
133+
taint_res=$?
134+
echo "exit error is -> $taint_res"
135+
if [ $taint_res -gt 0 ]; then echo "$index" >> failed-labs.txt ; fi
136+
index=$((index + 1))
137+
set -euo pipefail
138+
done < ssh_list.txt
139+
# echo >> failed-labs.txt
140+
}
141+
142+
91143
function taint_and_reapply() {
92144
if [ ! -s failed-labs.txt ]; then
93145
echo "No failed VMs detected"
@@ -107,50 +159,47 @@ function taint_and_reapply() {
107159

108160
# function run_universe_from_seed() {
109161
# if [[ "$AU_FROM_SEED" != "true" ]]; then return; fi
110-
# echo "Launching a-universe-from-seed..."
111-
# mapfile -t ssh_lines < ssh_list.txt
112-
# for i in "${!ssh_lines[@]}"; do
113-
# line="${ssh_lines[$i]}"
162+
# echo "Running a-universe-from-seed..."
163+
# while IFS= read -r line; do
114164
# ip=$(echo "$line" | awk '{print $3}')
115165
# name=$(echo "$line" | awk '{print $2}')
116166
# password=$(echo "$line" | awk '{print $5}')
117167

118168
# sshpass -p "$password" ssh -o StrictHostKeyChecking=no \
119169
# "lab@${ip}" \
120170
# "tmux new-session -d -s aus-run './a-universe-from-seed.sh'"
121-
# done
171+
# done < ssh_list.txt
122172
# }
123173

124-
function run_universe_from_seed() {
125-
if [[ "$AU_FROM_SEED" != "true" ]]; then return; fi
126-
echo "Launching a-universe-from-seed..."
127-
while IFS= read -r line; do
128-
ip=$(echo "$line" | awk '{print $3}')
129-
name=$(echo "$line" | awk '{print $2}')
130-
password=$(echo "$line" | awk '{print $5}')
131174

132-
sshpass -p "$password" ssh -o StrictHostKeyChecking=no \
133-
"lab@${ip}" \
134-
"tmux new-session -d -s aus-run './a-universe-from-seed.sh'"
135-
done < ssh_list.txt
136-
}
137175

138176
# === RUN STEPS ===
139177
sleep 90 # Wait for VMs to be ready
140178

141179
check_lab_vm_connections
142-
validate_lab_vms
143180

181+
if [[ "$AU_FROM_SEED" = "false" ]]; then
182+
validate_lab_vms
183+
else
184+
validate_universe_from_seed
185+
fi
144186

145187
if [[ "$TAINT_REBUILD" = "true" && ! -s failed-labs.txt ]]; then
146188
taint_and_reapply
189+
147190
terraform output -json > tf-outputs.json
148191
terraform output -raw labs > ssh_list.txt
149-
validate_lab_vms
192+
sed -i 's/"//g' ssh_list.txt
193+
echo >> ssh_list.txt
194+
195+
if [[ "$AU_FROM_SEED" = "false" ]]; then
196+
validate_lab_vms
197+
else
198+
validate_universe_from_seed
199+
fi
200+
150201
else
151202
echo "Tainting and rebuilding is disabled, skipping..."
152203
fi
153204

154-
run_universe_from_seed
155-
156205
echo "AUFN Test completed successfully!"

.github/workflows/deploy-aufn.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ on:
3636
au_from_seed:
3737
description: Run 'A Universe From Seed'?
3838
type: boolean
39-
default: false
39+
default: true
4040
debug_mode:
4141
description: Keep 'Test' up to debug?
4242
type: boolean
4343
default: false
4444
taint_rebuild:
4545
description: Taint and rebuild failed Lab VMs?
4646
type: boolean
47-
default: false
47+
default: true
4848
secrets:
4949
BASTION_TEST_PASSWORD:
5050
required: true
@@ -98,6 +98,36 @@ jobs:
9898
${{ secrets.CLOUDS_YAML }}
9999
EOF
100100
101+
- name: Append MoTD if type Deployment
102+
if: ${{ inputs.deployment_type == 'Deployment' }}
103+
run: |
104+
echo "cat <<EOF | sudo tee /etc/motd
105+
106+
Welcome to the Kayobe Lab!
107+
108+
Optionally, attach to a tmux session in case the connection drops:
109+
110+
tmux
111+
112+
To view the script that was used to deploy the seed in this instance:
113+
114+
< a-seed-from-nothing.sh
115+
116+
To view the instructions for deploying the control plane:
117+
118+
< a-universe-from-seed.sh
119+
120+
To see this directions again:
121+
122+
< /etc/motd
123+
124+
EOF" >> setup-user.sh
125+
126+
- name: Conditionally inject a-universe-from-seed.sh execution
127+
if: ${{ inputs.au_from_seed == true }}
128+
run: |
129+
sed -i '/a-seed-from-nothing.out",/a \ "sudo -u lab /home/lab/a-universe-from-seed.sh | sudo -u lab tee -a /home/lab/a-universe-from-seed.out",' openstack-device.tf
130+
101131
- name: Generate terraform.tfvars
102132
run: |
103133
cat << EOF > terraform.tfvars
@@ -132,7 +162,6 @@ jobs:
132162
env:
133163
OS_CLOUD: ${{ vars.OS_CLOUD }}
134164

135-
136165
- name: Terraform Apply
137166
id: tf_apply
138167
run: |

setup-user.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,3 @@ cat <<EOF | sudo tee -a /etc/sudoers.d/91-wheel-group
1818
1919
EOF
2020

21-
cat <<EOF | sudo tee /etc/motd
22-
23-
Welcome to the Kayobe Lab!
24-
25-
Optionally, attach to a tmux session in case the connection drops:
26-
27-
tmux
28-
29-
To view the script that was used to deploy the seed in this instance:
30-
31-
< a-seed-from-nothing.sh
32-
33-
To view the instructions for deploying the control plane:
34-
35-
< a-universe-from-seed.sh
36-
37-
To see this directions again:
38-
39-
< /etc/motd
40-
41-
EOF

0 commit comments

Comments
 (0)