Set group priority on node group

Hi team,

I am facing issue to configure priority for node group.
i have 16 nodes cluster and there are four group of users groupA, groupB, groupC, groupD. each group own four nodes of group called nodegroupA, nodegroupB, nodegroupC, nodegroupD.

now case is all users can run jobs on all nodes or node groups but they may get priority on their own group, exmpl :- if groupA submit job they get priority on nodegroupA.
please help how to configure.

Regards
Pradeep
,

Please find the solution below:

I am assuming here by groups, you mean LINUX groups ( if that is the case then it is good).

1 Create a custom resource called nodegroup

 qmgr -c "create resource nodegroup  type=string_array,flag=h"
  1. edit $PBS_HOME/sched_priv/sched_config

a. add the “nodegroup” to resources: line
resources: “aoe, ncpus, …, nodegroup”

b. update the job_sort_key as below
job_sort_key: “job_priority HIGH all”

Save and Exit

  1. kill -HUP < PID of the PBS Scheduler >

  2. Assign the nodes to the respective groups

for i in “nodes of groupA” ; do qmgr -c “set node $i resources_available.nodegroup=nodegroupA” ; done
for i in “nodes of groupB” ; do qmgr -c “set node $i resources_available.nodegroup=nodegroupB” ; done
for i in “nodes of groupC” ; do qmgr -c “set node $i resources_available.nodegroup=nodegroupC” ; done
for i in “nodes of groupD” ; do qmgr -c “set node $i resources_available.nodegroup=nodegroupD” ; done

  1. create queues for each group

qmgr -c “create queue groupA,groupB,groupC,groupD queue_type=e,started=t,enabled=t”
qmgr -c “set queue groupA default_chunk.nodegroup=nodegroupA”
qmgr -c “set queue groupB default_chunk.nodegroup=nodegroupB”
qmgr -c “set queue groupC default_chunk.nodegroup=nodegroupC”
qmgr -c “set queue groupD default_chunk.nodegroup=nodegroupD”

  1. Update and use the below queuejob hook to your requirements :
    Update the groupnames assigned to the queues:
    Please update the indentation in the below python source:

cat nodegrouppriority.py

#APAEGBP
#1. Save the hook

#2. To deploy the hook as root:
#qmgr -c ‘create hook nodegrouppriority event=queuejob’
#qmgr -c 'import hook nodegrouppriority application/x-python default nodegrouppriority.py.

#3. To disable the hook as root:
#qmgr -c ‘set hook nodegrouppriority enabled=false’

#4. To delete the hook as root:

#qmgr -c ‘delete hook nodegrouppriority’

import pbs, grp, pwd, os

e = pbs.event()
j = e.job

#Get the username
user = str(e.requestor)

#Get the group name of the user
groups = [g.gr_name for g in grp.getgrall() if user in g.gr_mem]
gid = pwd.getpwnam(user).pw_gid
groups.append(grp.getgrgid(gid).gr_name)

#Get queuename
if j.queue == ‘’:
q = pbs.server().default_queue.name
else:
q = j.queue.name

#Get the groupname based on the queue
if str(q) == “groupA”:
groupname = “groupA”
if str(q) == “groupB”:
groupname = “groupB”
if str(q) == “groupC”:
groupname = “groupC”
if str(q) == “groupD”:
groupname= “groupD”

#Check whether the user belongs to the groupname based
#on the queue the user submitted to and set the priority
if groupname in groups:
j.Priority=100
else:
j.Priority=10

#Check the PBS Server logs for these debug messages
pbs.logmsg(pbs.LOG_DEBUG, “USER NAME is %s” % str(user))
pbs.logmsg(pbs.LOG_DEBUG, “QUEUE NAME is %s” % str(q))
pbs.logmsg(pbs.LOG_DEBUG, “GROUP NAME is %s” % groupname)
pbs.logmsg(pbs.LOG_DEBUG, “JOB PRIORITY set to %s” % str(j.Priority))

hope this helps.

Thanks Adarsh for help, can it possible without group dedicated queues ?

100% yes, It is not mandatory to map group to the queues (the above was a sample solution)
You can handle any logic in the hook .