Commit 0a58f581 authored by Gary Wong's avatar Gary Wong

Add (advisory only) admission control check to nalloc.

parent bbb4ebe0
......@@ -183,8 +183,9 @@ sub Stringify($)
my $pid = $self->pid();
my $nodes = $self->nodes();
my $type = $self->type();
my $start = localtime( $self->start() );
my $end = localtime( $self->end() );
my $start = defined( $self->start() ) ? localtime( $self->start() ) :
"epoch";
my $end = defined( $self->end() ) ? localtime( $self->end() ) : "forever";
return "[Reservation: $pid, ${nodes}x${type}, ${start}-${end}]";
}
......
......@@ -61,6 +61,7 @@ use Project;
use User;
use Node;
use EmulabFeatures;
use Reservation;
#
# Turn off line buffering on output
......@@ -162,8 +163,10 @@ foreach my $n (@node_names) {
}
TBDebugTimeStamp("nalloc checked all node permissions");
# Must lock this table!
DBQueryFatal("lock tables reserved write");
# Argh, MySQL locking rules are horrendous! These locks are required by
# low-level library routines; this is a horrible violation of abstraction;
# and it's all MySQL's fault...
DBQueryFatal("lock tables reserved write, users read, groups read, projects read, future_reservations read, nodes as n read, reserved as r read, experiments as e read, next_reserve as nr read, `geni-cm`.geni_slices as s read");
TBDebugTimeStamp("nalloc locked tables");
# Make a list of nodes to reserve.
......@@ -217,6 +220,49 @@ if ($debug) {
print "List Ready: @nodes\nError=$error\n";
}
# Admission control check -- advisory only, for now.
if ($debug) {
print "Running advisory admission control verification...\n";
}
my %types = ();
foreach my $node (@nodes) {
$types{ $node->type() } = 1;
}
foreach my $type ( keys( %types ) ) {
my $reservations = Reservation->LookupAll( $type );
if( !Reservation->IsFeasible( $reservations, \$error ) ) {
print "Existing admission control violation for type $type: $error\n";
print "Omitting admission control verification.\n";
goto admissionfailure;
}
}
my $endtime = $experiment->autoswap() ?
time() + $experiment->autoswap_timeout * 60 : undef;
foreach my $type ( keys( %types ) ) {
my $reservations = Reservation->LookupAll( $type );
foreach my $node (@nodes) {
if( $node->type() eq $type ) {
my $res = Reservation->CreateImmediate( $pid, undef,
$this_user->uid(),
$endtime, $type, 1 );
if ($debug) {
print "$res\n";
}
push( @$reservations, $res );
}
}
if( !Reservation->IsFeasible( $reservations, \$error ) ) {
print "Admission control violation for type $type: $error\n";
goto admissionfailure;
}
}
admissionfailure:
# Now make the reservations in the DB.
if ((!$noalloc || $partial) && (@nodes || @oldnodes)) {
print "Reserving nodes...\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment