Skip to content
Snippets Groups Projects
Commit fa6b256e authored by Mark A. Grondona's avatar Mark A. Grondona
Browse files

cgroups: Support configurable cgroup mount dir in release agent

The example cgroup release agent packaged and installed with
SLURM assumes a base directory of /cgroup for all mounted
subsystems. Since the mount point is now configurable in SLURM,
this script needs to be augmented to determine the location
of the subsystem mount point at runtime.
parent c9ea11b5
No related branches found
No related tags found
No related merge requests found
...@@ -13,10 +13,21 @@ ...@@ -13,10 +13,21 @@
# to ensure coherency of the cgroups contents. # to ensure coherency of the cgroups contents.
# #
base_path=/cgroup
progname=$(basename $0) progname=$(basename $0)
subsystem=${progname##*_} subsystem=${progname##*_}
orphancg=${base_path}/${subsystem}/orphan
get_mount_dir()
{
local lssubsys=$(type -p lssubsys)
if [ -x $lssubsys ]; then
$lssubsys -m $subsystem | awk '{print $2}'
else
awk "/release_agent=$0/ { print \$2 }"
fi
}
mountdir=$(get_mount_dir)
orphancg=${mountdir}/orphan
if [[ $# -eq 0 ]] if [[ $# -eq 0 ]]
then then
...@@ -30,8 +41,8 @@ then ...@@ -30,8 +41,8 @@ then
mkdir ${orphancg} mkdir ${orphancg}
case ${subsystem} in case ${subsystem} in
cpuset) cpuset)
cat ${base_path}/${subsystem}/cpuset.cpus > ${orphancg}/cpuset.cpus cat ${mountdir}/cpuset.cpus > ${orphancg}/cpuset.cpus
cat ${base_path}/${subsystem}/cpuset.mems > ${orphancg}/cpuset.mems cat ${mountdir}/cpuset.mems > ${orphancg}/cpuset.mems
;; ;;
*) *)
;; ;;
...@@ -42,7 +53,7 @@ fi ...@@ -42,7 +53,7 @@ fi
if [[ $# -eq 1 ]] if [[ $# -eq 1 ]]
then then
rmcg=${base_path}/${subsystem}$@ rmcg=${mountdir}$@
# try to extract the uid cgroup from the input one # try to extract the uid cgroup from the input one
# ( extract /uid_% from /uid%/job_*...) # ( extract /uid_% from /uid%/job_*...)
...@@ -51,13 +62,13 @@ then ...@@ -51,13 +62,13 @@ then
then then
# not a slurm job pattern, perhaps the uidcg, just remove # not a slurm job pattern, perhaps the uidcg, just remove
# the dir with a lock and exit # the dir with a lock and exit
flock -x ${base_path}/${subsystem} -c "rmdir ${rmcg}" flock -x ${mountdir} -c "rmdir ${rmcg}"
exit $? exit $?
fi fi
if [[ -d ${base_path}/${subsystem} ]] if [[ -d ${mountdir} ]]
then then
flock -x ${base_path}/${subsystem} -c "$0 sync $@" flock -x ${mountdir} -c "$0 sync $@"
fi fi
exit $? exit $?
...@@ -68,7 +79,7 @@ elif [[ $# -eq 2 ]] && [[ $1 == "sync" ]] ...@@ -68,7 +79,7 @@ elif [[ $# -eq 2 ]] && [[ $1 == "sync" ]]
then then
shift shift
rmcg=${base_path}/${subsystem}$@ rmcg=${mountdir}$@
uidcg=${rmcg%/job_*} uidcg=${rmcg%/job_*}
# remove this cgroup # remove this cgroup
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment