@@ -12,21 +12,66 @@ systemctl is-active systemd-cryptsetup@var.service
1212systemctl is-active systemd-cryptsetup@var\\ x2dtmp.service
1313mangosctl bootstrap
1414mangosctl sudo enroll -g{vault-server,{nomad,consul}-{server,client}}s 127.0.0.1
15- mangosctl sudo -- nomad job run /usr/share/mangos/test.nomad
16- tries=10
17- while ! mangosctl sudo -- nomad alloc logs -namespace=admin -task server -job test | grep SUCCESS
15+ mangosctl sudo -- nomad job run -detach /usr/share/mangos/test.nomad
16+
17+ echo " Waiting for job allocation to start..."
18+ echo " Current time: $( date) "
19+ tries=60
20+ success=0
21+
22+ # Temporarily disable exit-on-error for polling loop
23+ set +e
24+
25+ while [ $tries -gt 0 ]
1826do
19- if [ $tries -le 0 ]
27+ # Get allocation status first
28+ alloc_status=$( mangosctl sudo -- nomad job allocs -namespace=admin -json test 2> /dev/null | jq -r ' .[0].ClientStatus // empty' )
29+
30+ if [ -n " $alloc_status " ]; then
31+ echo " [$( date +%H:%M:%S) ] Allocation status: $alloc_status "
32+ else
33+ echo " [$( date +%H:%M:%S) ] No allocation yet..."
34+ fi
35+
36+ # Check if logs are available and contain SUCCESS
37+ if mangosctl sudo -- nomad alloc logs -namespace=admin -task server -job test 2> /dev/null | grep -q SUCCESS
2038 then
21- echo " Test job did not complete successfully"
22- exit 1
39+ echo " Test job completed successfully!"
40+ success=1
41+ break
42+ fi
43+
44+ # If allocation failed, break early
45+ if [ " $alloc_status " = " failed" ]; then
46+ echo " Allocation failed, breaking loop"
47+ break
2348 fi
49+
2450 tries=$(( tries - 1 ))
25- echo " Sleeping 10 seconds. "
51+ echo " [ $( date +%H:%M:%S ) ] Waiting... ( $tries attempts remaining) "
2652 sleep 10
27- echo " Trying again. $tries tries left"
2853done
2954
55+ # Re-enable exit-on-error
56+ set -e
57+
58+ if [ $success -eq 0 ]
59+ then
60+ echo " Test job did not complete successfully after 10 minutes"
61+ echo " === Job Status ==="
62+ mangosctl sudo -- nomad job status -namespace=admin test || true
63+ echo " === Allocation Logs ==="
64+ mangosctl sudo -- nomad alloc logs -namespace=admin -task server -job test 2>&1 || true
65+ echo " === Allocation Status ==="
66+ alloc_id=$( mangosctl sudo -- nomad job allocs -namespace=admin -json test 2> /dev/null | jq -r ' .[0].ID // empty' )
67+ if [ -n " $alloc_id " ]; then
68+ mangosctl sudo -- nomad alloc status -namespace=admin " $alloc_id " || true
69+ else
70+ echo " No allocations found for job"
71+ fi
72+ exit 1
73+ fi
74+
3075echo " ===> Validating Recovery Keys"
3176machine_id=$( cat /etc/machine-id)
3277
@@ -38,7 +83,7 @@ if [ -z "$luks_partitions" ]; then
3883else
3984 # Test 1: Verify recovery keys exist in Vault
4085 for device in $luks_partitions ; do
41- partition=$( lsblk -nlo PARTLABEL /dev/$device )
86+ partition=$( lsblk -n -o PARTLABEL " /dev/$device " 2> /dev/null | tr -d ' \n\r\t ' )
4287 if ! mangosctl sudo -- vault kv get " secrets/mangos/recovery-keys/${machine_id} /${partition} " > /dev/null 2>&1 ; then
4388 echo " ERROR: Recovery key not found in Vault for ${partition} "
4489 exit 1
0 commit comments