Limit Users

Limiting users is typically not the best choice, as alternative approaches may be used to enforce policies without incurring low resource utilization issues. However, in some cases, limiting users may be the best solution and this section discusses several ways in which an administrator can limit the number of jobs that a user can run.

Control the User:x Resource

For every user 'x' there is a resource called "User:x" that controls the overall number of jobs that the user can run. The default value is "unlimited" and an administrator can set the resource to a different value with vtk_resourcemap_set, as in the following examples:
vtk_resourcemap_set User:john 5 
vtk_resourcemap_set User:mary unlimited
vtk_resourcemap_set User:phil 0
vtk_resourcemap_set User:hoag -max 2 -map "hpux RAM/200"
These VTK calls can go into the resources.tcl file or they could be executed directly with vovsh -x ...:
% nc cmd vovsh -x 'vtk_resourcemap_set User:tarzan 88'

Similarly, you can control the Group:* resource to limit the jobs within a FairShare group or the Priority:* resource to limit all jobs that use certain ranges of priorities. The use of these limits is highly discouraged.

The default value of the User:* resource is controlled by the server configuration parameter resMapUserDefault, which can be set in the policy.tcl file, as in this example:
# Fragment of policy.tcl file.
set config(resMapUserDefault) 30

The configuration applies to all new resources that are created after the default has been changed.

Control the Tool:* Resource

While the resources mentioned in the previous section are always used, the resource Tool:x is only used if it is defined for a given tool. The "tool for a job" is defined as the tail of the command line argument that is not a known VOV wrapper. For example, for the command vw /bin/cp aa bb, the tool is the string cp.

For example, if you want to limit the number of cp jobs that are executed at any one time, or you want to route them to a specific set of machines, you can use the resource map "Tool:cp", as in:
vtk_resourcemap_set Tool:cp -max 3

Limits in Jobclasses

If you are using a jobclass, it is easy to define limits for both the jobclass and also for the users of that jobclass. This is best shown with this complete example taken from $VOVDIR/etc/jobclass/examples/hsim.tcl:

File: hsim.tcl
set classDescription "A template for an hsim class"
set classEditable     1
lappend VOV_JOB_DESC(resources) License:hsim
lappend VOV_JOB_DESC(resources) Limit:q_hsim_@USER@
lappend VOV_JOB_DESC(resources) Limit:r_hsim_@GROUP@ 
lappend VOV_JOB_DESC(resources) CPUS/1 percent/1 RAM/20

proc initJobClass {} {
    # Executed by vovresourced at startup.
    # vtk_resourcemap_set License:hsim 8
    # vtk_flexlm_monitor hsim License:hsim 

    # Revoke requested/not-used resources after 2 minutes.    
    vtk_jobclass_set_revocation_delay "hsim" 2m

    # Warn after 2h, kill after 4h of idleness.    
    vtk_jobclass_set_idle_delays    "hsim" 2h 4h

    vtk_jobclass_set_max_reschedule "hsim"  2

    TIMEVAR hsim {
	Fri,Sat,Sun {
	    vtk_resourcemap_set_limit Limit:q_hsim_@USER@  3
	    vtk_resourcemap_set_limit Limit:r_hsim_@GROUP@ 5
	20:30-24:00,0:00-5:30 {
	    vtk_resourcemap_set_limit Limit:q_hsim_@USER@  1
	    vtk_resourcemap_set_limit Limit:r_hsim_@GROUP@ 2
	default {
	    vtk_resourcemap_set_limit Limit:q_hsim_@USER@  1
	    vtk_resourcemap_set_limit Limit:r_hsim_@GROUP@ 2

Self Limiting

Some users may like to self limit the jobs that can be executed concurrently by using the option -limit in nc run:
% nc run -limit 3 -f listOfJobs