@@ -707,10 +707,10 @@ allocate-run-nomadcloud() {
707
707
&& jqtest ' .node.utxo_lmdb' " ${dir} " /profile.json \
708
708
&& jqtest ' (.cluster.nomad.host_volumes.producer | length) > 0' " ${dir} " /profile.json
709
709
then
710
- # Index on the "host_volumes" array.
710
+ # Iterate over the profile's Nomad "host_volumes" array by key/index .
711
711
for host_volume_key in $( jq_tolist ' .cluster.nomad.host_volumes.producer | keys' " ${dir} " /profile.json)
712
712
do
713
- # Compare the SSD directory the node will use and volume destination.
713
+ # Compare defined node's SSD directory with this volume's destination.
714
714
local ssd_directory host_volume_destination
715
715
ssd_directory=" $( jq -r ' .node.ssd_directory' " ${dir} " /profile.json) "
716
716
host_volume_destination=" $( jq -r " .cluster.nomad.host_volumes.producer[${host_volume_key} ].destination" " ${dir} " /profile.json) "
@@ -721,10 +721,16 @@ allocate-run-nomadcloud() {
721
721
host_volume_source=" $( jq -r " .cluster.nomad.host_volumes.producer[${host_volume_key} ].source" " ${dir} " /profile.json) "
722
722
host_volume_path=" $( wb nomad clients ssh " ${client_name} " cat /etc/nomad.json | jq -r " .client.host_volume[\" ${host_volume_source} \" ].path" ) "
723
723
local rm_command
724
+ # Won't remove hidden files like ".mounted".
724
725
rm_command=" rm -rf \" ${host_volume_path} \" /*"
725
- msg " $( yellow " About to: \" ${rm_command} \" " ) "
726
- read -p " Hit enter to continue ..."
726
+ msg " $( yellow " Cleaning up SSD host volume. Executing: \" ${rm_command} \" on Nomad client \" ${client_name} \" (${client_id} ) ..." ) "
727
727
wb nomad clients ssh " ${client_name} " " ${rm_command} "
728
+ # Check that the directory is empty (hidden files ignored).
729
+ if wb nomad clients ssh " ${client_name} " " ls \" ${host_volume_path} \" /" | grep --invert-match --quiet -E " ^0$"
730
+ then
731
+ msg " $( yellow " WARNING: Nomad client \" ${client_name} \" (${client_id} ) still has files in \" ${host_volume_path} \" " ) "
732
+ read -p " Hit enter to continue ..."
733
+ fi
728
734
fi
729
735
done
730
736
fi
0 commit comments