Difference between revisions of "Access control scripts (admission rules)"
From Supercomputación y Cálculo Científico UIS
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | __NOTOC__ | |
| − | + | <div class="thumbnail img-thumbnail">http://wiki.sc3.uis.edu.co/images/a/a8/Logo_sc33.png</div> | |
| − | + | <p><div class="btn btn-primary"><i class="fa fa-long-arrow-left"></i> [[Job Scheduler OAR]]</div></p> | |
| − | + | <div class="column clearfix"> | |
| − | </ | + | <div class="col-md-14"> |
| + | <div class="well well-midnight"> | ||
| + | <h4>Access control scripts (admission_rules)</h4> | ||
| + | </div> | ||
| + | </div> | ||
| + | </div> | ||
| + | <div class="col-md-14"> | ||
| + | <div class="panel panel-darker-white-border"> | ||
| + | <div class="panel-heading"> | ||
| + | <h3 class="panel-title">OAR Administration</h3> | ||
| + | </div> | ||
| + | <div class="panel-body"> | ||
| + | <p> | ||
| + | |||
| + | These scripts must be entered in the sql table called "admission_rules" or can be added using oaradmin: | ||
| + | {{Command|<nowiki>oaradmin -a [rule_id] [-f file]</nowiki>}} | ||
To edit a rule: | To edit a rule: | ||
| − | {{Command|<nowiki> | + | {{Command|<nowiki>oaradmin -e [rule_id] [-f file]</nowiki>}} |
| − | oaradmin -e [rule_id] [-f file] | ||
| − | </nowiki>}} | ||
1. Maximum walltime: passive 336 hours, interactive 2 hours. | 1. Maximum walltime: passive 336 hours, interactive 2 hours. | ||
| Line 56: | Line 69: | ||
} | } | ||
} | } | ||
| − | 2. Limit jobs to allow at least one interactive job. | + | 2. Limit maximum jobs per user at a given time. |
| + | |||
| + | my $max_total_jobs = 2; | ||
| + | my $nb_jobs = $dbh->do(" SELECT job_id | ||
| + | FROM jobs | ||
| + | WHERE | ||
| + | job_user = '$user' AND | ||
| + | reservation = 'None' AND | ||
| + | (state = 'Waiting' | ||
| + | OR state = 'Hold' | ||
| + | OR state = 'toLaunch' | ||
| + | OR state = 'toAckReservation' | ||
| + | OR state = 'Launching' | ||
| + | OR state = 'Running' | ||
| + | OR state = 'Suspended' | ||
| + | OR state = 'Resuming' | ||
| + | OR state = 'Finishing') | ||
| + | "); | ||
| + | if ($nb_jobs >= $max_total_jobs){ | ||
| + | die("You cannot have more than $max_interactive_jobs interactive jobs at a time.\n"); | ||
| + | } | ||
| + | |||
| + | 3. Limit jobs to allow at least one interactive job. | ||
'''To be continued. | '''To be continued. | ||
source [http://wiki-oar.imag.fr/index.php/Customization_tips#Walltime_limit] | source [http://wiki-oar.imag.fr/index.php/Customization_tips#Walltime_limit] | ||
| + | |||
| + | </p> | ||
| + | </div> | ||
| + | </div> | ||
| + | </div> | ||
Latest revision as of 19:31, 9 April 2015

Access control scripts (admission_rules)
OAR Administration
These scripts must be entered in the sql table called "admission_rules" or can be added using oaradmin:
oaradmin -a [rule_id] [-f file]
To edit a rule:
oaradmin -e [rule_id] [-f file]
1. Maximum walltime: passive 336 hours, interactive 2 hours.
NOTE: The following script works in oar version 2.5
my $max_interactive_walltime = OAR::IO::sql_to_duration("2:00:00");
# 7 days = 168 hours
my $max_batch_walltime = OAR::IO::sql_to_duration("336:00:00");
foreach my $mold (@{$ref_resource_list}){
if (defined($mold->[1])){
if (($jobType eq "INTERACTIVE") and ($reservationField eq "None") and ($max_interactive_walltime < $mold->[1])){
print("[ADMISSION RULE] Walltime too big for an INTERACTIVE job so it is set to $max_interactive_walltime.\n");
$mold->[1] = $max_interactive_walltime;
}elsif ($max_batch_walltime < $mold->[1]){
print("[ADMISSION RULE] Walltime too big for a BATCH job so it is set to $max_batch_walltime.\n");
$mold->[1] = $max_batch_walltime;
}
}
}
NOTE: The following script works in oar version 2.4
update admission_rules set rule=
'my $max_interactive_walltime = iolib::sql_to_duration("2:00:00")\;
# 14 days = 336 hours
my $max_batch_walltime = iolib::sql_to_duration("336:00:00")\;
foreach my $mold (@{$ref_resource_list}){
if (defined($mold->[1])){
if (($jobType eq "INTERACTIVE") and ($reservationField eq "None") and ($max_interactive_walltime < $mold->[1])){
print("[ADMISSION RULE] Walltime too big for an INTERACTIVE job so it is set to $max_interactive_walltime.\n")\;
$mold->[1] = $max_interactive_walltime\;
}elsif ($max_batch_walltime < $mold->[1]){
print("[ADMISSION RULE] Walltime too big for a BATCH job so it is set to $max_batch_walltime.\n")\;
$mold->[1] = $max_batch_walltime\;
}
}
}' where id=11;
NOTE: The previous script replaces the original rule 11 (in the current guane setup) That original rule is presented below:
# Set the maximum walltime
my $max_walltime = iolib::sql_to_duration("12:00:00");
if (($jobType eq "INTERACTIVE") and ($reservationField eq "None")){
foreach my $mold (@{$ref_resource_list}){
if ((defined($mold->[1])) and ($max_walltime < $mold->[1])){
print("[ADMISSION RULE] Walltime to big for an INTERACTIVE job so it is set to $max_walltime.\n");
$mold->[1] = $max_walltime;
}
}
}
2. Limit maximum jobs per user at a given time.
my $max_total_jobs = 2;
my $nb_jobs = $dbh->do(" SELECT job_id
FROM jobs
WHERE
job_user = '$user' AND
reservation = 'None' AND
(state = 'Waiting'
OR state = 'Hold'
OR state = 'toLaunch'
OR state = 'toAckReservation'
OR state = 'Launching'
OR state = 'Running'
OR state = 'Suspended'
OR state = 'Resuming'
OR state = 'Finishing')
");
if ($nb_jobs >= $max_total_jobs){
die("You cannot have more than $max_interactive_jobs interactive jobs at a time.\n");
}
3. Limit jobs to allow at least one interactive job.
To be continued.
source [1]
