This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wiki:some_examples_of_admission_rules [2017/05/11 15:32] – [Example 5:] mvesin | wiki:some_examples_of_admission_rules [2020/04/07 22:01] (current) – [Example 5: verify correct resources definitions] neyron | ||
---|---|---|---|
Line 138: | Line 138: | ||
</ | </ | ||
- | ==== Example 4: | + | ==== Example 4: limit access to a queue, based on usernames set in a file ==== |
- | + | ||
- | Limit access to a queue, based on usernames set in a file | + | |
==Answer== | ==Answer== | ||
Line 163: | Line 161: | ||
- | ==== Example 5: ==== | + | ==== Example 5: give a more privilege to the owners of nodes ==== |
Give a more privilege to the owners of nodes (e.g. people who payed for the nodes) to submit, by restricting others to besteffort jobs: | Give a more privilege to the owners of nodes (e.g. people who payed for the nodes) to submit, by restricting others to besteffort jobs: | ||
* non-owners compete on the resources according to the scheduling policy of the besteffort queue ; | * non-owners compete on the resources according to the scheduling policy of the besteffort queue ; | ||
Line 248: | Line 246: | ||
(There may be some limitations in that property filtering, which could allow malicious users to overcome the usage policy) | (There may be some limitations in that property filtering, which could allow malicious users to overcome the usage policy) | ||
+ | ==== Example 5: verify correct resources definitions ==== | ||
+ | |||
+ | Verify that the '' | ||
+ | |||
+ | OAR resource request hierarchies are implicit in the OAR database, but they can be enforced by an admission rule. | ||
+ | |||
+ | Lets assume that valid resources hierarchies are: | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Here both switch > cluster, or cluster > switch can be valid (some clusters spread their nodes on many switches, some clusters share a same switch). A GPU never spans several CPUs. The disk property defines special resources to reserve disks on hosts, independently from cpu, gpu and core properties. The license property is yet a completely independent type of resource. | ||
+ | |||
+ | Any of those resources properties can define a valid hierarchy or resources, for instance: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | But incorrect hierachry should raise an error: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ==Answer== | ||
+ | |||
+ | <code perl> | ||
+ | |||
+ | # definition of the valid implicit hierarchies of resources. | ||
+ | my %valid_children = ( | ||
+ | # both cluster > switch and switch > cluster are relevant | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ); | ||
+ | |||
+ | # nodes is synonym of host | ||
+ | my %aliases = ( | ||
+ | " | ||
+ | ); | ||
+ | |||
+ | # valid values are in one of the possible hierarchies | ||
+ | my %valid_resources; | ||
+ | foreach my $key (keys %valid_children) { | ||
+ | $valid_resources{$key} = undef; | ||
+ | foreach my $child (@{%valid_children{$key}}) { | ||
+ | $valid_resources{$child} = undef; | ||
+ | } | ||
+ | } | ||
+ | my @valid_resources = keys %valid_resources; | ||
+ | |||
+ | # test the user's request for possible errors | ||
+ | foreach my $mold (@{$ref_resource_list}) { # loop on all moldable resources requests (oarsub -l ... -l ...) | ||
+ | foreach my $r (@{$mold-> | ||
+ | my @resources_hierarchy; | ||
+ | my $parent_resource; | ||
+ | foreach my $h (@{$r-> | ||
+ | if(!grep { $_ eq $h-> | ||
+ | die(" | ||
+ | } | ||
+ | if (!grep { $_ eq $h-> | ||
+ | push @resources_hierarchy, | ||
+ | } else { | ||
+ | # catching the case `oarsub -l / | ||
+ | push @resources_hierarchy, | ||
+ | die(" | ||
+ | } | ||
+ | if (defined($parent_resource)) { | ||
+ | if (!grep { $_ eq $h-> | ||
+ | die(" | ||
+ | } | ||
+ | } | ||
+ | if (exists $aliases{$h-> | ||
+ | $parent_resource = $aliases{$h-> | ||
+ | } else { | ||
+ | $parent_resource = $h-> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ |