Skip to content

Commit

Permalink
Make sure that the apptainer instance is dead
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Nov 17, 2024
1 parent 0cf54b6 commit 85f2fac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/TestHarness/schedulers/hpc_template
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ if ((return_code > 128)); then
echo "Apptainer exited with code $return_code, using $new_return_code instead"
return_code=$new_return_code
fi
# If we're using --sharens, make sure the instance is dead
if [ "$APPTAINER_SHARENS" == "1" ] && [ -n "$APPTAINER_CONFIGDIR" ]; then
apptainer instance list
set +e
instance_list=$(apptainer instance list | tail -n +2)
if [ -n "$instance_list" ]; then
instance_name=$(echo "$instance_list" | awk '{print $1}')
instance_pid=$(echo "$instance_list" | awk '{print $2}')
echo "Killing running apptainer instance \"${instance_name}\" in ${instance_pid}"
apptainer instance stop ${instance_name}
if ps -p $instance_pid > /dev/null; then
kill -9 $instance_pid
fi
fi
set -e
fi
{%- endif %}
# Load the execution time; we use a tail here because the process will
# include a comment about a non-zero status first if the exit code is nonzero
Expand Down

0 comments on commit 85f2fac

Please sign in to comment.