Commit d7aa8b1a authored by Gary Wong's avatar Gary Wong

Make admission control aware of project_reservations end times.

parent e4fe75cb
...@@ -522,34 +522,49 @@ sub LookupAll($$;$) ...@@ -522,34 +522,49 @@ sub LookupAll($$;$)
"UNIX_TIMESTAMP( e.expt_swapped ) + " . "UNIX_TIMESTAMP( e.expt_swapped ) + " .
"e.autoswap_timeout * 60, e.autoswap, " . "e.autoswap_timeout * 60, e.autoswap, " .
"nr.pid, UNIX_TIMESTAMP( s.expires ), " . "nr.pid, UNIX_TIMESTAMP( s.expires ), " .
"s.lockdown, n.reserved_pid FROM nodes AS n " . "s.lockdown, n.reserved_pid, " .
"UNIX_TIMESTAMP( pr.end ) " .
"FROM nodes AS n " .
"LEFT OUTER JOIN " . "LEFT OUTER JOIN " .
"reserved AS r ON n.node_id=r.node_id " . "reserved AS r ON n.node_id=r.node_id " .
"LEFT OUTER JOIN experiments AS e ON " . "LEFT OUTER JOIN experiments AS e ON " .
"r.pid=e.pid AND r.eid=e.eid LEFT " . "r.pid=e.pid AND r.eid=e.eid LEFT " .
"OUTER JOIN next_reserve AS nr ON " . "OUTER JOIN next_reserve AS nr ON " .
"n.node_id=nr.node_id LEFT OUTER JOIN " . "n.node_id=nr.node_id LEFT OUTER JOIN " .
"project_reservations AS pr ON " .
"n.reserved_pid=pr.pid AND " .
"n.reservation_name=pr.name " .
"LEFT OUTER JOIN" .
"`geni-cm`.geni_slices AS s ON " . "`geni-cm`.geni_slices AS s ON " .
"e.eid_uuid=s.uuid " . "e.eid_uuid=s.uuid " .
"WHERE n.type='$type' GROUP BY " . "WHERE n.type='$type' GROUP BY " .
"e.pid, e.eid, n.reserved_pid, nr.pid" : "e.pid, e.eid, n.reserved_pid, nr.pid, " .
"UNIX_TIMESTAMP( pr.end )" :
"SELECT COUNT(*), e.pid, e.eid, " . "SELECT COUNT(*), e.pid, e.eid, " .
"e.expt_swap_uid, " . "e.expt_swap_uid, " .
"UNIX_TIMESTAMP( e.expt_swapped ) + " . "UNIX_TIMESTAMP( e.expt_swapped ) + " .
"e.autoswap_timeout * 60, e.autoswap, " . "e.autoswap_timeout * 60, e.autoswap, " .
"nr.pid, NULL, " . "nr.pid, NULL, " .
"NULL, n.reserved_pid FROM nodes AS n " . "NULL, n.reserved_pid, " .
"UNIX_TIMESTAMP( pr.end ) " .
"FROM nodes AS n " .
"LEFT OUTER JOIN " . "LEFT OUTER JOIN " .
"reserved AS r ON n.node_id=r.node_id " . "reserved AS r ON n.node_id=r.node_id " .
"LEFT OUTER JOIN experiments AS e ON " . "LEFT OUTER JOIN experiments AS e ON " .
"r.pid=e.pid AND r.eid=e.eid LEFT " . "r.pid=e.pid AND r.eid=e.eid LEFT " .
"OUTER JOIN next_reserve AS nr ON " . "OUTER JOIN next_reserve AS nr ON " .
"n.node_id=nr.node_id WHERE n.type='$type' " . "n.node_id=nr.node_id " .
"GROUP BY e.pid, e.eid, n.reserved_pid, nr.pid"; "LEFT OUTER JOIN " .
"project_reservations AS pr ON " .
"n.reserved_pid=pr.pid AND " .
"n.reservation_name=pr.name " .
"WHERE n.type='$type' " .
"GROUP BY e.pid, e.eid, n.reserved_pid, " .
"nr.pid, UNIX_TIMESTAMP( pr.end )";
my $query_result = DBQueryWarn( $query ); my $query_result = DBQueryWarn( $query );
while( my($count, $pid, $eid, $uid, $end, $autoswap, $next_reserve, while( my($count, $pid, $eid, $uid, $end, $autoswap, $next_reserve,
$slice_expire, $slice_lockdown, $reserved_pid ) = $slice_expire, $slice_lockdown, $reserved_pid, $pr_end ) =
$query_result->fetchrow_array() ) { $query_result->fetchrow_array() ) {
my $endtime; my $endtime;
...@@ -573,9 +588,12 @@ sub LookupAll($$;$) ...@@ -573,9 +588,12 @@ sub LookupAll($$;$)
} }
# If reserved_pid is set, assume the node is assigned to the # If reserved_pid is set, assume the node is assigned to the
# project forever. # project forever, unless there's an end time in a corresponding
if( defined( $reserved_pid ) ) { # project_reservations entry.
$endtime = undef; if( defined( $reserved_pid ) &&
( !defined( $pr_end ) || !defined( $endtime ) ||
$pr_end > $endtime ) ) {
$endtime = $pr_end;
} }
# Consider nodes in reloading to be available. One important # Consider nodes in reloading to be available. One important
...@@ -598,6 +616,14 @@ sub LookupAll($$;$) ...@@ -598,6 +616,14 @@ sub LookupAll($$;$)
my $res = CreateCommon( $class, undef, undef, undef, 0, undef, my $res = CreateCommon( $class, undef, undef, undef, 0, undef,
$type, $count ); $type, $count );
push( @reservations, $res ); push( @reservations, $res );
} elsif( defined( $endtime ) ) {
# The nodes have a reserved_pid, but there's a known
# end time (the current experiment end, or the
# project_reservations end, whichever is later)... mark
# them as available after that.
my $res = CreateCommon( $class, $pid, $eid, $uid, 0, $endtime,
$type, $count );
push( @reservations, $res );
} }
} }
......
...@@ -189,9 +189,9 @@ my $endtime = Reservation->ExpectedEnd( $experiment ); ...@@ -189,9 +189,9 @@ my $endtime = Reservation->ExpectedEnd( $experiment );
# low-level library routines; this is a horrible violation of abstraction; # low-level library routines; this is a horrible violation of abstraction;
# and it's all MySQL's fault... # and it's all MySQL's fault...
if( $PGENISUPPORT ) { if( $PGENISUPPORT ) {
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, reservation_version write"); 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, project_reservations as pr read, reservation_version write");
} else { } else {
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, reservation_version write"); 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, project_reservations as pr read, reservation_version write");
} }
TBDebugTimeStamp("nalloc locked tables"); TBDebugTimeStamp("nalloc locked tables");
......
#
# This is the definitions file for Gary on APT.
#
. defs-apt
TBOPSEMAIL=gtw@flux.utah.edu
TBLOGSEMAIL=gtw@flux.utah.edu
TBWWWEMAIL=gtw@flux.utah.edu
TBAPPROVALEMAIL=gtw@flux.utah.edu
TBAUDITEMAIL=gtw@flux.utah.edu
TBSTATEDEMAIL=gtw@flux.utah.edu
TBTESTSUITEEMAIL=gtw@flux.utah.edu
WWW=www.apt.emulab.net/dev/gtw
THISHOMEBASE=GTWAPT
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