fix(check-deployment): add some error handling and fix the "one-node" mode

This commit is contained in:
sinavir 2024-02-23 17:35:25 +01:00
parent d1326f3f06
commit d55faceefb

View file

@ -88,14 +88,23 @@ echo "$RESULTS" | @jq@/bin/jq -c '.[]' |
while IFS=$'\n' read -r c; do while IFS=$'\n' read -r c; do
machine=$(echo "$c" | @jq@/bin/jq -r '.machine') machine=$(echo "$c" | @jq@/bin/jq -r '.machine')
if [[ -n ${node-} ]] && [[ "$machine" != "$node" ]]; then
echo "Skipping ${machine}"
continue
fi
expected_path=$(echo "$c" | @jq@/bin/jq -r '.path') expected_path=$(echo "$c" | @jq@/bin/jq -r '.path')
domain=$(echo "$c" | @jq@/bin/jq -r '.domain') domain=$(echo "$c" | @jq@/bin/jq -r '.domain')
drv_path=$(echo "$c" | @jq@/bin/jq -r '.drv') drv_path=$(echo "$c" | @jq@/bin/jq -r '.drv')
current_path=$(retrieve_current_system "$domain") err=0
current_path=$(retrieve_current_system "$domain") || err=1
if [[ "1" == "${err}" ]] ; then
echo "❌ failed to contact $domain !"
continue
fi
if [ "$expected_path" == "$current_path" ] ; then if [ "$expected_path" == "$current_path" ] ; then
echo "$machine -> OK" echo "$machine -> OK"
elif [[ -n ${diff-} ]] ; then elif [[ -n ${diff-} ]] ; then
nix-copy-closure --from "root@$domain" "$current_path" nix-copy-closure --from "root@$domain" "$current_path"
nix-store -r "$drv_path" nix-store -r "$drv_path"
@ -103,7 +112,7 @@ while IFS=$'\n' read -r c; do
@nvd@/bin/nvd diff "$expected_path" "$current_path" @nvd@/bin/nvd diff "$expected_path" "$current_path"
return_status=1 return_status=1
else else
echo "$machine -> error:" echo "☠️ $machine -> error:"
echo " - Expected system: $expected_path" echo " - Expected system: $expected_path"
echo " - Current system: $current_path" echo " - Current system: $current_path"
return_status=1 return_status=1