[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 8/9] mg-allocate: Better error handling when no candidates



Spot when our db search revealed no candidates for the resources to
allocate, and:
 - when doing an immediate allocation, call it an error
 - when doing a planned allocation, cause it to prevent allocation
   on this iteration, and print a suitably unreassuring message

Previously it would simply say `nothing available'.

Implement this as follows:
 - Report lack of candidates as $ok=-1 from alloc_1rescand
 - In alloc_1res, return this -1 as with any non-zero $ok
 - Handle the new $ok at all the call sites, in particular
 - In plan(), rename `allok' to `worstok' and have it be
   the worst relevant $ok value.  If $ok gives -1, return
   undef, rather than a booking list, to the allocator core.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 mg-allocate |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/mg-allocate b/mg-allocate
index 4c32fa8..54a7af3 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -211,6 +211,9 @@ END
         $got_shareix= $candrow->{shareix};
         $ok=1; last;
     }
+    if (!$resq->rows) {
+       return (-1,undef);
+    }
     return ($ok, { Allocate => $allocate,
                   Shareix => $got_shareix,
                   Info => "$resname ($restype/$resname/$got_shareix)"
@@ -248,6 +251,8 @@ sub execute () {
             if (!$ok) {
                 logm("nothing available for $res, sorry");
                 $allok=0;
+            } elsif ($ok < 0) {
+               die "*** no candidates for $res! ***\n";
             } else {
                 logm("processed $res (shareix=$got->{Shareix})");
                push @got, $got;
@@ -314,17 +319,19 @@ sub plan () {
        logm("best at $planned->{Start} is ".showposs(\@reqlist));
        die unless $planned;
 
-        my $allok=0;
+        my $worstok=0;
         if ($mayalloc && !$planned->{Start}) {
-            $allok=1;
+            $worstok=1;
 
             alloc_prep();
 
             foreach my $req (@reqlist) {
                 my ($ok, $got) = alloc_1res($req->{Ident});
+               $worstok = $ok if $ok < $worstok;
                 if (!$ok) {
                     logm("failed to allocate $req->{Ident}!");
-                    $allok=0;
+                } elsif ($ok < 0) {
+                   logm("*** no candidates for $req->{Ident}! ***");
                 } else {
                     $req->{GotShareix}= $got->{Shareix};
                    push @got, $got;
@@ -332,9 +339,12 @@ sub plan () {
             }
         }
 
-        if ($allok) {
+        if ($worstok > 0) {
             logm("allocated, notifying...");
-        } else {
+        } elsif ($worstok < 0) {
+           logm("*** problems, maybe missing resources? ***");
+           return (0, undef);
+       } else {
             logm("booking...");
         }
 
@@ -346,7 +356,7 @@ sub plan () {
                 Start => $planned->{Start},
                 End => $planned->{Start} + $duration,
             };
-            if ($allok) {
+            if ($worstok > 0) {
                 $book->{Allocated}= {
                     Task => $tid,
                     Shareix => $req->{GotShareix},
@@ -355,7 +365,7 @@ sub plan () {
             push @bookings, $book;
         }
 
-        return ($allok, { Bookings => \@bookings });
+        return ($worstok, { Bookings => \@bookings });
     });
     loggot(@got);
 }
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.