Commit eaeed4b0 authored by Gary Wong's avatar Gary Wong

Fix admission control when an experiment has nodes already allocated.

(The original approach was reusing the existing experiment record when
trying to repeat admission control.  This did properly decrement the
"used nodes" count, so that reallocating the same node to the same
experiment wasn't counted twice; but unfortunately it didn't
effectively increase the "free nodes" count and so it was still
possible to encounter spurious failures.  This could affect both
swapmod and RedeemTicket.)
parent f75b994f
...@@ -569,7 +569,7 @@ sub IsFeasible($$;$$$) ...@@ -569,7 +569,7 @@ sub IsFeasible($$;$$$)
my ($class, $reservations, $error, $conflicttime, $conflictcount) = @_; my ($class, $reservations, $error, $conflicttime, $conflictcount) = @_;
my @timeline = (); my @timeline = ();
my $free; my $free = 0;
foreach my $reservation ( @$reservations ) { foreach my $reservation ( @$reservations ) {
my $start; my $start;
...@@ -600,7 +600,7 @@ sub IsFeasible($$;$$$) ...@@ -600,7 +600,7 @@ sub IsFeasible($$;$$$)
'reserved' => -$reservation->nodes() }; 'reserved' => -$reservation->nodes() };
} else { } else {
# Available resources. Provides nodes for all time. # Available resources. Provides nodes for all time.
$free = $reservation->nodes(); $free += $reservation->nodes();
} }
push( @timeline, $start ) if( defined( $start->{'t'} ) ); push( @timeline, $start ) if( defined( $start->{'t'} ) );
...@@ -805,7 +805,6 @@ sub ExpectedEnd($$) { ...@@ -805,7 +805,6 @@ sub ExpectedEnd($$) {
sub MaxSwapIn($$$) { sub MaxSwapIn($$$) {
my ($class, $experiment, $type) = @_; my ($class, $experiment, $type) = @_;
my $reservation;
my $MAX = 10000; my $MAX = 10000;
my $overflow; my $overflow;
...@@ -814,22 +813,23 @@ sub MaxSwapIn($$$) { ...@@ -814,22 +813,23 @@ sub MaxSwapIn($$$) {
if( defined( $res->pid() ) && defined( $res->eid() ) && if( defined( $res->pid() ) && defined( $res->eid() ) &&
$res->pid() eq $experiment->pid() && $res->pid() eq $experiment->pid() &&
$res->eid() eq $experiment->eid() ) { $res->eid() eq $experiment->eid() ) {
$reservation = $res; # Found existing nodes already reserved to the experiment we're
last; # trying to allocate. In this context, they should be considered
# as available.
$res->{'PID'} = undef;
$res->{'EID'} = undef;
$res->SetStart( -1 );
$res->SetEnd( undef );
} }
} }
if( defined( $reservation ) ) { my $reservation = CreateImmediate( $class, $experiment->pid(),
$reservation->SetNodes( $MAX ); $experiment->eid(),
} else { $experiment->swapper(),
$reservation = CreateImmediate( $class, $experiment->pid(), ExpectedEnd( $class, $experiment ),
$experiment->eid(), $type, $MAX );
$experiment->swapper(),
ExpectedEnd( $class, $experiment ),
$type, $MAX );
push( @$reservations, $reservation ); push( @$reservations, $reservation );
}
while( $reservation->nodes() > 0 && while( $reservation->nodes() > 0 &&
!IsFeasible( $class, $reservations, undef, undef, \$overflow ) ) { !IsFeasible( $class, $reservations, undef, undef, \$overflow ) ) {
......
...@@ -730,6 +730,7 @@ sub RunAssign($$) ...@@ -730,6 +730,7 @@ sub RunAssign($$)
} }
# Bound the results to avoid future reservation conflicts. # Bound the results to avoid future reservation conflicts.
Reservation->FlushAll();
my $reservation_bounds = Reservation->MaxSwapInMap( $experiment ); my $reservation_bounds = Reservation->MaxSwapInMap( $experiment );
foreach my $type ( keys( %$reservation_bounds ) ) { foreach my $type ( keys( %$reservation_bounds ) ) {
if( exists( $admission_control{ $type } ) ) { if( exists( $admission_control{ $type } ) ) {
......
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