Commit b5c775be authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add admission control checks to both tbswap and to assign_wrapper.in.

There are two different kinds of admission control checks, hence two
locations.

* From tbswap, easy checks are made (like, too many nodes of a real
  type), or trying to the use robot lab when its closed.

* From assign_wrapper.in. Because of virtual types, and because assign
  is the ultimate descision maker, we need to pass into assign per
  physical type limits, and let it deal with how virtual types map to
  physical types, and whether it exceeds the limits. So, when called
  from assign_wrapper, libadminctrl returns a hash of types and the
  counts the current experiment is limited to. That is put into the
  ptop file where assign deals with it.

If admission control goes sour, then just turn off the sitevar for it:
'swap/use_admission_control'
parent c838e5e5
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -76,6 +76,7 @@ use lib "@prefix@/lib";
use libdb;
use libtestbed;
use Node;
use libadminctrl;
#
# assign_wrapper Settings
......@@ -278,6 +279,9 @@ my %plinks = ();
my %virtnodes = ();
my %v2vmap = ();
# Admission control counts
my %admission_control = ();
#
# Support for experiment modify. We create v2p and v2v mappings of the
# current topology so we can figure out how its changed after assign
......@@ -458,6 +462,14 @@ my %vnode2rtabid = ();
printdb "Generating TOP file.\n";
TBDebugTimeStamp("TOP started");
#
# Do admission control test right away.
#
if (!$toponly) {
fatal("Failed admission control checks!")
if (!TBAdmissionControlCheck($UID, $pid, $eid, \%admission_control));
}
#
# vtypes are a funny mix beteween physical and virtual state, so we have to
# load them before getting the PhysInfo.
......@@ -559,6 +571,7 @@ while (1) {
$currentrun++;
}
TBDebugTimeStamp("assign_loop finished");
die("foo\n");
#
# Run assign once.
......@@ -597,6 +610,18 @@ sub RunAssign ()
system("ptopgen $ptopargs > $ptopfile");
TBDebugTimeStamp("ptopgen finished");
if (scalar(keys(%admission_control))) {
open(PTOP, ">> $ptopfile") or
return -1;
foreach my $typeclass (keys(%admission_control)) {
my $count = $admission_control{$typeclass};
print PTOP "set-type-limit $typeclass $count\n";
}
close(PTOP);
}
TBDebugTimeStamp("assign started");
# Run assign
my $cmdargs = "$ptopfile $topfile";
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -45,6 +45,7 @@ $ENV{'PATH'} = "/usr/bin:$TBROOT/libexec:$TBROOT/libexec/ns2ir" .
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use libadminctrl;
require exitonwarn; # exitonwarn isn't really a module, so just require it
#
......@@ -208,11 +209,26 @@ elsif ($swapop eq "update") {
#
if ($firewalled) {
print STDERR "Cannot modify firewalled experiment right now.\n";
print "Failingly finished swap-$swapop for $pid/$eid. ".TBTimeStamp()."\n";
print "Failingly finished swap-$swapop for $pid/$eid. " .
TBTimeStamp() . "\n";
TBDebugTimeStamp("tbswap $swapop finished (failed)");
exit(1);
}
#
# Before swapout, do cursory admission control to see if the
# modified experiment will be swappable. assign_wrapper does a
# more stringent check using assign.
#
print STDERR "Checking with Admission Control ...\n";
if (! TBAdmissionControlCheck($UID, $pid, $eid, undef)) {
print STDERR "Admission control failure!\n";
print "Failingly finished swap-$swapop for $pid/$eid. " .
TBTimeStamp() . "\n";
TBDebugTimeStamp("tbswap $swapop finished (failed)");
exit(1);
}
#
# Update.
#
......@@ -288,6 +304,19 @@ elsif ($swapop eq "in") {
# Swap in
#
my $retries = 2;
#
# Before real swapin, do cursory admission control. assign_wrapper does
# a more stringent check using assign.
#
print STDERR "Checking with Admission Control ...\n";
if (! TBAdmissionControlCheck($UID, $pid, $eid, undef)) {
print STDERR "Admission control failure!\n";
print "Failingly finished swap-$swapop for $pid/$eid. " .
TBTimeStamp() . "\n";
TBDebugTimeStamp("tbswap $swapop finished (failed)");
exit(1);
}
$errors = doSwapin(REAL);
......
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